From 14bed07c99843f2d196fd6b3481492f3a28c7adc Mon Sep 17 00:00:00 2001 From: Lionel Debroux Date: Sun, 9 Dec 2007 09:47:42 +0100 Subject: [PATCH] winhelp: Fix memory leaks (found by Smatch). --- programs/winhelp/hlpfile.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/programs/winhelp/hlpfile.c b/programs/winhelp/hlpfile.c index ff041ec4a5e..3a9717a78de 100644 --- a/programs/winhelp/hlpfile.c +++ b/programs/winhelp/hlpfile.c @@ -1613,7 +1613,12 @@ static BOOL HLPFILE_UncompressLZ77_Phrases(HLPFILE* hlpfile) phrases.offsets = HeapAlloc(GetProcessHeap(), 0, sizeof(unsigned) * (num + 1)); phrases.buffer = HeapAlloc(GetProcessHeap(), 0, dec_size); - if (!phrases.offsets || !phrases.buffer) return FALSE; + if (!phrases.offsets || !phrases.buffer) + { + HeapFree(GetProcessHeap(), 0, phrases.offsets); + HeapFree(GetProcessHeap(), 0, phrases.buffer); + return FALSE; + } for (i = 0; i <= num; i++) phrases.offsets[i] = GET_USHORT(buf, head_size + 2 * i) - 2 * num - 2; @@ -1672,7 +1677,12 @@ static BOOL HLPFILE_Uncompress_Phrases40(HLPFILE* hlpfile) phrases.offsets = HeapAlloc(GetProcessHeap(), 0, sizeof(unsigned) * (num + 1)); phrases.buffer = HeapAlloc(GetProcessHeap(), 0, dec_size); - if (!phrases.offsets || !phrases.buffer) return FALSE; + if (!phrases.offsets || !phrases.buffer) + { + HeapFree(GetProcessHeap(), 0, phrases.offsets); + HeapFree(GetProcessHeap(), 0, phrases.buffer); + return FALSE; + } #define getbit() (ptr += (mask < 0), mask = mask*2 + (mask<=0), (*ptr & mask) != 0)