mirror of
https://github.com/tobast/libunwind-eh_elf.git
synced 2024-11-30 02:27: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:
parent
fd2fa63a6c
commit
8c94e12429
1 changed files with 11 additions and 6 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue