dbghelp: Fix allocation error in image_load_debugaltlink.

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Eric Pouech 2021-11-22 15:20:54 +01:00 committed by Alexandre Julliard
parent f10635ab08
commit 789512beee
1 changed files with 4 additions and 3 deletions

View File

@ -671,9 +671,9 @@ struct image_file_map* image_load_debugaltlink(struct image_file_map* fmap, stru
*/ */
sect_len = image_get_map_size(&debugaltlink_sect); sect_len = image_get_map_size(&debugaltlink_sect);
id = memchr(data, '\0', sect_len); id = memchr(data, '\0', sect_len);
if (id) if (id++)
{ {
id++; unsigned idlen = (const BYTE*)data + sect_len - id;
fmap_link = HeapAlloc(GetProcessHeap(), 0, sizeof(*fmap_link)); fmap_link = HeapAlloc(GetProcessHeap(), 0, sizeof(*fmap_link));
if (fmap_link) if (fmap_link)
{ {
@ -691,7 +691,8 @@ struct image_file_map* image_load_debugaltlink(struct image_file_map* fmap, stru
{ {
static const WCHAR globalDebugDirW[] = static const WCHAR globalDebugDirW[] =
{'/','u','s','r','/','l','i','b','/','d','e','b','u','g','/','.','b','u','i','l','d','-','i','d','/'}; {'/','u','s','r','/','l','i','b','/','d','e','b','u','g','/','.','b','u','i','l','d','-','i','d','/'};
dst = HeapAlloc(GetProcessHeap(), 0, sizeof(globalDebugDirW) + (3 + filename_len) * sizeof(WCHAR)); dst = HeapAlloc(GetProcessHeap(), 0,
sizeof(globalDebugDirW) + (3 + filename_len + idlen * 2) * sizeof(WCHAR));
if (dst) if (dst)
{ {
WCHAR* p; WCHAR* p;