[APPCOMPAT] Fix a memory leak in a failure case (CID 1401161), a 0-length memset...
authorMark Jansen <mark.jansen@reactos.org>
Mon, 27 Feb 2017 18:54:57 +0000 (18:54 +0000)
committerMark Jansen <mark.jansen@reactos.org>
Mon, 27 Feb 2017 18:54:57 +0000 (18:54 +0000)
svn path=/trunk/; revision=73999

reactos/dll/appcompat/apphelp/hsdb.c
reactos/dll/appcompat/shims/shimlib/implement_shim.inl

index fe58f2e..805ac5c 100644 (file)
@@ -65,7 +65,9 @@ HSDB WINAPI SdbInitDatabase(DWORD flags, LPCWSTR path)
             case SDB_DATABASE_MAIN_SHIM: name = shim; break;
             case SDB_DATABASE_MAIN_MSI: name = msi; break;
             case SDB_DATABASE_MAIN_DRIVERS: name = drivers; break;
-            default: return NULL;
+            default:
+                SdbReleaseDatabase(sdb);
+                return NULL;
         }
         SdbGetAppPatchDir(NULL, buffer, 128);
         memcpy(buffer + lstrlenW(buffer), name, SdbpStrlen(name));
index 186cdf8..f784caa 100644 (file)
@@ -39,7 +39,8 @@ PHOOKAPI WINAPI SHIM_OBJ_NAME(GetHookAPIs)(DWORD fdwReason, PCSTR pszCmdLine, PD
         SHIM_OBJ_NAME(g_szCommandLine) = "";
     }
     SHIM_OBJ_NAME(g_pAPIHooks) = ShimLib_ShimMalloc(sizeof(HOOKAPI) * SHIM_NUM_HOOKS);
-    ZeroMemory(SHIM_OBJ_NAME(g_pAPIHooks), sizeof(HOOKAPI) * SHIM_NUM_HOOKS);
+    if (SHIM_NUM_HOOKS)
+        ZeroMemory(SHIM_OBJ_NAME(g_pAPIHooks), sizeof(HOOKAPI) * SHIM_NUM_HOOKS);
     *pdwHookCount = SHIM_NUM_HOOKS;
 
 #ifdef SHIM_NOTIFY_FN