Commit d394df4a authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

msi: Fix memory leak on realloc failure in search_directory (cppcheck).

parent 6c1dd0f2
...@@ -875,7 +875,7 @@ static UINT search_directory( MSIPACKAGE *package, MSISIGNATURE *sig, const WCHA ...@@ -875,7 +875,7 @@ static UINT search_directory( MSIPACKAGE *package, MSISIGNATURE *sig, const WCHA
{ {
UINT rc; UINT rc;
DWORD attr; DWORD attr;
LPWSTR val = NULL; WCHAR *val = NULL, *new_val;
TRACE("%p, %p, %s, %d, %p\n", package, sig, debugstr_w(path), depth, appValue); TRACE("%p, %p, %s, %d, %p\n", package, sig, debugstr_w(path), depth, appValue);
...@@ -920,12 +920,19 @@ static UINT search_directory( MSIPACKAGE *package, MSISIGNATURE *sig, const WCHA ...@@ -920,12 +920,19 @@ static UINT search_directory( MSIPACKAGE *package, MSISIGNATURE *sig, const WCHA
if (attr != INVALID_FILE_ATTRIBUTES && (attr & FILE_ATTRIBUTE_DIRECTORY) && if (attr != INVALID_FILE_ATTRIBUTES && (attr & FILE_ATTRIBUTE_DIRECTORY) &&
val && val[lstrlenW(val) - 1] != '\\') val && val[lstrlenW(val) - 1] != '\\')
{ {
val = realloc(val, (wcslen(val) + 2) * sizeof(WCHAR)); new_val = realloc(val, (wcslen(val) + 2) * sizeof(WCHAR));
if (!val) if (!new_val)
{
free(val);
val = NULL;
rc = ERROR_OUTOFMEMORY; rc = ERROR_OUTOFMEMORY;
}
else else
{
val = new_val;
PathAddBackslashW(val); PathAddBackslashW(val);
} }
}
*appValue = val; *appValue = val;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment