1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-11-26 17:17:39 +01:00

(_UPT_find_proc_info): Fix potential crash due to uninitialized pointer.

Be sure to clear pi->unwind_info when looking up the kernel table and
not needing the unwind-info.  Otherwise, _UPT_put_unwind_info() may
erroneously call free() on the pointer, even though that space wasn't
malloc'd, leading to crashes..
This commit is contained in:
David Mosberger-Tang 2006-07-26 15:43:23 -06:00
parent fd2fa63a6c
commit 8c94e12429

View file

@ -376,14 +376,19 @@ _UPT_find_proc_info (unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi,
without ill effects. */
int ret = tdep_search_unwind_table (unw_local_addr_space, ip, di, pi,
need_unwind_info, arg);
if (ret >= 0 && need_unwind_info)
if (ret >= 0)
{
void *mem = malloc (pi->unwind_info_size);
if (!need_unwind_info)
pi->unwind_info = NULL;
else
{
void *mem = malloc (pi->unwind_info_size);
if (!mem)
return -UNW_ENOMEM;
memcpy (mem, pi->unwind_info, pi->unwind_info_size);
pi->unwind_info = mem;
if (!mem)
return -UNW_ENOMEM;
memcpy (mem, pi->unwind_info, pi->unwind_info_size);
pi->unwind_info = mem;
}
}
return ret;
}