aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpionere <pionere@freemail.hu>2025-02-26 16:10:49 +0100
committerpionere <pionere@freemail.hu>2025-02-26 16:10:49 +0100
commit8e1f843c940f72e07acb33933e50c974509f774d (patch)
tree8fa3a82f2cb2d3cb358454096fcca640c20f18dd
parente01d93cc8ae743cfe2da5450854c5d2e3a939265 (diff)
fix crash when the allocation of pbHeaderBuffer fails
-rw-r--r--src/SFileOpenArchive.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/SFileOpenArchive.cpp b/src/SFileOpenArchive.cpp
index 587aa96..217feca 100644
--- a/src/SFileOpenArchive.cpp
+++ b/src/SFileOpenArchive.cpp
@@ -268,7 +268,9 @@ bool WINAPI SFileOpenArchive(
// Allocate the MPQhandle
if(dwErrCode == ERROR_SUCCESS)
{
- if((ha = STORM_ALLOC(TMPQArchive, 1)) == NULL)
+ if((ha = STORM_ALLOC(TMPQArchive, 1)) != NULL)
+ memset(ha, 0, sizeof(TMPQArchive));
+ else
dwErrCode = ERROR_NOT_ENOUGH_MEMORY;
}
@@ -290,7 +292,6 @@ bool WINAPI SFileOpenArchive(
DWORD dwHeaderID;
bool bSearchComplete = false;
- memset(ha, 0, sizeof(TMPQArchive));
ha->dwValidFileFlags = MPQ_FILE_VALID_FLAGS;
ha->pfnHashString = HashStringSlash;
ha->pStream = pStream;