From 6591ee92a2259381683916c87540c56892456e7a Mon Sep 17 00:00:00 2001 From: Nelson Garcia Date: Mon, 5 Nov 2018 13:23:21 -0800 Subject: [PATCH] Remove memory leak in loadzip.cpp * Call `unzClose(file)` outside of the assert clause. In Release mode, any statement in an assert clause is not called, causing a memory leak. If the file does not close successfully, `assert(FAIL)` is called. --- loadzip.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/loadzip.cpp b/loadzip.cpp index b59f8f7b..2e57179b 100644 --- a/loadzip.cpp +++ b/loadzip.cpp @@ -257,7 +257,8 @@ bool8 LoadZip (const char *zipname, uint32 *TotalFileSize, uint8 *buffer) if (!(port == UNZ_END_OF_LIST_OF_FILE || port == UNZ_OK) || filesize == 0 || (len > 5 && strcasecmp(zipname + len - 5, ".msu1") == 0 && strcasecmp(filename, "program.rom") != 0)) { - assert(unzClose(file) == UNZ_OK); + if (unzClose(file) != UNZ_OK) + assert(FALSE); return (FALSE); }