From 9bca01da8e7cc4965f5c4b905ff63b405838973f Mon Sep 17 00:00:00 2001 From: Steve Checkoway Date: Mon, 21 Jul 2008 10:34:43 +0000 Subject: [PATCH] If there is nothing to copy, return. This fixes an assert in stl since m_pFile->m_sBuf[m_iFilePos] is not dereferencable if m_iFilePos is the size of the file. --- stepmania/src/RageFileDriverMemory.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stepmania/src/RageFileDriverMemory.cpp b/stepmania/src/RageFileDriverMemory.cpp index a93a2c17a3..c8b5a5e5c7 100644 --- a/stepmania/src/RageFileDriverMemory.cpp +++ b/stepmania/src/RageFileDriverMemory.cpp @@ -51,13 +51,14 @@ RageFileObjMem::~RageFileObjMem() int RageFileObjMem::ReadInternal( void *buffer, size_t bytes ) { - m_pFile->m_Mutex.Lock(); + LockMut(m_pFile->m_Mutex); m_iFilePos = min( m_iFilePos, GetFileSize() ); bytes = min( bytes, (size_t) GetFileSize() - m_iFilePos ); + if( bytes == 0 ) + return 0; memcpy( buffer, &m_pFile->m_sBuf[m_iFilePos], bytes ); m_iFilePos += bytes; - m_pFile->m_Mutex.Unlock(); return bytes; }