[APPCOMPAT] Fix a memory leak in a failure case (CID 1401161), a 0-length memset that is detected 3 times (CID 1401069, 1401064, 1401062)

svn path=/trunk/; revision=73999
This commit is contained in:
Mark Jansen 2017-02-27 18:54:57 +00:00
parent c7991b4c1d
commit 6a3bffaeba
2 changed files with 5 additions and 2 deletions

View 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));

View 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