From 007cc5cd8a4ede70516bf2bf15dd62af01dfc8f0 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Fri, 16 Nov 2018 22:02:46 +0100 Subject: [PATCH] [ACGENRAL] Don't leak memory on failure in InitIgnoreFreeLibrary() CID 1441306 --- dll/appcompat/shims/genral/ignorefreelib.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/dll/appcompat/shims/genral/ignorefreelib.c b/dll/appcompat/shims/genral/ignorefreelib.c index b0c7ebb991e..01b472fc069 100644 --- a/dll/appcompat/shims/genral/ignorefreelib.c +++ b/dll/appcompat/shims/genral/ignorefreelib.c @@ -97,7 +97,7 @@ static VOID InitIgnoreFreeLibrary(PCSTR CommandLine) if (!names[n]) { SHIM_WARN("Unable to allocate %u bytes\n", cur - prev + 2); - return; + goto fail; } n++; prev = cur + 1; @@ -106,11 +106,23 @@ static VOID InitIgnoreFreeLibrary(PCSTR CommandLine) if (!names[n]) { SHIM_WARN("Unable to allocate last string\n"); - return; + goto fail; } g_Names = names; g_NameCount = count; + return; + +fail: + --n; + while (n >= 0) + { + if (names[n]) + ShimLib_ShimFree((PVOID)names[n]); + + --n; + } + ShimLib_ShimFree(names); } BOOL WINAPI SHIM_OBJ_NAME(Notify)(DWORD fdwReason, PVOID ptr)