Commit 7a441eaf authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

dbghelp: Handle memory allocation failure in image_locate_build_id_target (cppcheck).

parent 3e5a9565
......@@ -660,6 +660,7 @@ static BOOL image_locate_build_id_target(struct image_file_map* fmap, const BYTE
p = malloc(sizeof(L"/usr/lib/debug/.build-id/") +
(idlen * 2 + 1) * sizeof(WCHAR) + sizeof(L".debug"));
if (!p) goto fail;
wcscpy(p, L"/usr/lib/debug/.build-id/");
z = p + wcslen(p);
if (idlen)
......@@ -684,9 +685,11 @@ static BOOL image_locate_build_id_target(struct image_file_map* fmap, const BYTE
sz = GetEnvironmentVariableW(L"WINEHOMEDIR", NULL, 0);
if (sz)
{
p = realloc(p, sz * sizeof(WCHAR) +
z = realloc(p, sz * sizeof(WCHAR) +
sizeof(L"\\.cache\\debuginfod_client\\") +
idlen * 2 * sizeof(WCHAR) + sizeof(L"\\debuginfo") + 500);
if (!z) goto fail;
p = z;
GetEnvironmentVariableW(L"WINEHOMEDIR", p, sz);
z = p + sz - 1;
wcscpy(z, L"\\.cache\\debuginfod_client\\");
......@@ -703,6 +706,7 @@ static BOOL image_locate_build_id_target(struct image_file_map* fmap, const BYTE
}
TRACE("not found\n");
fail:
free(p);
HeapFree(GetProcessHeap(), 0, fmap_link);
return FALSE;
......
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