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
{
UINT rc;
DWORD attr;
LPWSTR val = NULL;
WCHAR *val = NULL, *new_val;
TRACE("%p, %p, %s, %d, %p\n", package, sig, debugstr_w(path), depth, appValue);
......@@ -920,11 +920,18 @@ static UINT search_directory( MSIPACKAGE *package, MSISIGNATURE *sig, const WCHA
if (attr != INVALID_FILE_ATTRIBUTES && (attr & FILE_ATTRIBUTE_DIRECTORY) &&
val && val[lstrlenW(val) - 1] != '\\')
{
val = realloc(val, (wcslen(val) + 2) * sizeof(WCHAR));
if (!val)
new_val = realloc(val, (wcslen(val) + 2) * sizeof(WCHAR));
if (!new_val)
{
free(val);
val = NULL;
rc = ERROR_OUTOFMEMORY;
}
else
{
val = new_val;
PathAddBackslashW(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