https://git.reactos.org/?p=reactos.git;a=commitdiff;h=007cc5cd8a4ede70516bf2bf15dd62af01dfc8f0

commit 007cc5cd8a4ede70516bf2bf15dd62af01dfc8f0
Author:     Pierre Schweitzer <[email protected]>
AuthorDate: Fri Nov 16 22:02:46 2018 +0100
Commit:     Pierre Schweitzer <[email protected]>
CommitDate: Fri Nov 16 22:07:09 2018 +0100

    [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 b0c7ebb991..01b472fc06 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)

Reply via email to