1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-12-02 11:17:38 +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,7 +376,11 @@ _UPT_find_proc_info (unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi,
without ill effects. */ without ill effects. */
int ret = tdep_search_unwind_table (unw_local_addr_space, ip, di, pi, int ret = tdep_search_unwind_table (unw_local_addr_space, ip, di, pi,
need_unwind_info, arg); need_unwind_info, arg);
if (ret >= 0 && need_unwind_info) if (ret >= 0)
{
if (!need_unwind_info)
pi->unwind_info = NULL;
else
{ {
void *mem = malloc (pi->unwind_info_size); void *mem = malloc (pi->unwind_info_size);
@ -385,6 +389,7 @@ _UPT_find_proc_info (unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi,
memcpy (mem, pi->unwind_info, pi->unwind_info_size); memcpy (mem, pi->unwind_info, pi->unwind_info_size);
pi->unwind_info = mem; pi->unwind_info = mem;
} }
}
return ret; return ret;
} }
else else