diff --git a/3rdParty/StormLib/src/SFileReadFile.cpp b/3rdParty/StormLib/src/SFileReadFile.cpp index bd7eafb30..f8eb9d50e 100644 --- a/3rdParty/StormLib/src/SFileReadFile.cpp +++ b/3rdParty/StormLib/src/SFileReadFile.cpp @@ -711,7 +711,12 @@ bool STORMAPI SFileReadFile(HANDLE hFile, void * pvBuffer, DWORD dwToRead, LPDWO // If the file is local file, read the data directly from the stream if(hf->pStream != NULL) { - nError = ReadMpqFileLocalFile(hf, pvBuffer, hf->dwFilePos, dwToRead, &dwBytesRead); + ULONGLONG pos; + if (!FileStream_GetPos(hf->pStream, &pos)) { + SetLastError(ERROR_CAN_NOT_COMPLETE); + return false; + } + nError = ReadMpqFileLocalFile(hf, pvBuffer, pos, dwToRead, &dwBytesRead); } #ifdef FULL // If the file is a patch file, we have to read it special way @@ -739,7 +744,8 @@ bool STORMAPI SFileReadFile(HANDLE hFile, void * pvBuffer, DWORD dwToRead, LPDWO } // Increment the file position - hf->dwFilePos += dwBytesRead; + if(hf->pStream == NULL) + hf->dwFilePos += dwBytesRead; // Give the caller the number of bytes read if(pdwRead != NULL)