diff options
author | Ladislav Zezula <zezula@volny.cz> | 2024-04-21 22:35:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-21 22:35:07 +0200 |
commit | 3b65b373bc822a0ee0410edb80fa4ecfc0b454da (patch) | |
tree | 6d46b40a782aa282e60b3e9583d5a9120287c3b3 /src/SFileReadFile.cpp | |
parent | 605222393594f5885b877bfc0086dae756674965 (diff) | |
parent | 7250eca739f060dd6984b9ea74a9fbb8b0a7c353 (diff) |
Merge pull request #346 from ladislav-zezula/LZ_GabeShermanFoundBugs
Fixed bugs found by Gabe Sherman
Diffstat (limited to 'src/SFileReadFile.cpp')
-rw-r--r-- | src/SFileReadFile.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/SFileReadFile.cpp b/src/SFileReadFile.cpp index 8ab5f48..180d428 100644 --- a/src/SFileReadFile.cpp +++ b/src/SFileReadFile.cpp @@ -261,6 +261,8 @@ static DWORD ReadMpqFileSingleUnit(TMPQFile * hf, void * pvBuffer, DWORD dwFileP // If the file sector is not loaded yet, do it if(hf->dwSectorOffs != 0) { + DWORD cbRawData = hf->dwDataSize; + // Is the file compressed? if(pFileEntry->dwFlags & MPQ_FILE_COMPRESS_MASK) { @@ -268,11 +270,14 @@ static DWORD ReadMpqFileSingleUnit(TMPQFile * hf, void * pvBuffer, DWORD dwFileP pbCompressed = STORM_ALLOC(BYTE, pFileEntry->dwCmpSize); if(pbCompressed == NULL) return ERROR_NOT_ENOUGH_MEMORY; + + // Redirect reading pbRawData = pbCompressed; + cbRawData = pFileEntry->dwCmpSize; } // Load the raw (compressed, encrypted) data - if(!FileStream_Read(ha->pStream, &RawFilePos, pbRawData, pFileEntry->dwCmpSize)) + if(!FileStream_Read(ha->pStream, &RawFilePos, pbRawData, cbRawData)) { STORM_FREE(pbCompressed); return GetLastError(); |