From 8e1f843c940f72e07acb33933e50c974509f774d Mon Sep 17 00:00:00 2001 From: pionere Date: Wed, 26 Feb 2025 16:10:49 +0100 Subject: fix crash when the allocation of pbHeaderBuffer fails --- src/SFileOpenArchive.cpp | 5 +++-- 1 file 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; -- cgit v1.2.3