PR26388, objdump debug dump memory leaks
num_debug_info_entries is used not just as a count but also as a flag (DEBUG_INFO_UNAVAILABLE) after some errors. That means num_debug_info_entries can't be used when cleaning up malloc'd info. PR 26388 * dwarf.c (free_debug_memory): Free alloc_num_debug_info_entries of debug_information. Correct test of max_loc_offsets and max_range_lists. * rddbg.c (read_debugging_info): Free dhandle on error.
This commit is contained in:
parent
fc0efc4bd7
commit
82fcdb3938
3 changed files with 21 additions and 13 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2020-08-14 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
|
PR 26388
|
||||||
|
* dwarf.c (free_debug_memory): Free alloc_num_debug_info_entries
|
||||||
|
of debug_information. Correct test of max_loc_offsets and
|
||||||
|
max_range_lists.
|
||||||
|
* rddbg.c (read_debugging_info): Free dhandle on error.
|
||||||
|
|
||||||
2020-08-14 Alan Modra <amodra@gmail.com>
|
2020-08-14 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
* testsuite/binutils-all/mangled.s: Use dc.a rather than dc.d.
|
* testsuite/binutils-all/mangled.s: Use dc.a rather than dc.d.
|
||||||
|
|
|
@ -10777,19 +10777,16 @@ free_debug_memory (void)
|
||||||
|
|
||||||
if (debug_information != NULL)
|
if (debug_information != NULL)
|
||||||
{
|
{
|
||||||
if (num_debug_info_entries != DEBUG_INFO_UNAVAILABLE)
|
for (i = 0; i < alloc_num_debug_info_entries; i++)
|
||||||
{
|
{
|
||||||
for (i = 0; i < num_debug_info_entries; i++)
|
if (debug_information [i].max_loc_offsets)
|
||||||
{
|
|
||||||
if (!debug_information [i].max_loc_offsets)
|
|
||||||
{
|
{
|
||||||
free (debug_information [i].loc_offsets);
|
free (debug_information [i].loc_offsets);
|
||||||
free (debug_information [i].have_frame_base);
|
free (debug_information [i].have_frame_base);
|
||||||
}
|
}
|
||||||
if (!debug_information [i].max_range_lists)
|
if (debug_information [i].max_range_lists)
|
||||||
free (debug_information [i].range_lists);
|
free (debug_information [i].range_lists);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
free (debug_information);
|
free (debug_information);
|
||||||
debug_information = NULL;
|
debug_information = NULL;
|
||||||
alloc_num_debug_info_entries = num_debug_info_entries = 0;
|
alloc_num_debug_info_entries = num_debug_info_entries = 0;
|
||||||
|
|
|
@ -43,7 +43,8 @@ static void free_saved_stabs (void);
|
||||||
pointer. */
|
pointer. */
|
||||||
|
|
||||||
void *
|
void *
|
||||||
read_debugging_info (bfd *abfd, asymbol **syms, long symcount, bfd_boolean no_messages)
|
read_debugging_info (bfd *abfd, asymbol **syms, long symcount,
|
||||||
|
bfd_boolean no_messages)
|
||||||
{
|
{
|
||||||
void *dhandle;
|
void *dhandle;
|
||||||
bfd_boolean found;
|
bfd_boolean found;
|
||||||
|
@ -54,13 +55,13 @@ read_debugging_info (bfd *abfd, asymbol **syms, long symcount, bfd_boolean no_me
|
||||||
|
|
||||||
if (! read_section_stabs_debugging_info (abfd, syms, symcount, dhandle,
|
if (! read_section_stabs_debugging_info (abfd, syms, symcount, dhandle,
|
||||||
&found))
|
&found))
|
||||||
return NULL;
|
goto err_exit;
|
||||||
|
|
||||||
if (bfd_get_flavour (abfd) == bfd_target_aout_flavour)
|
if (bfd_get_flavour (abfd) == bfd_target_aout_flavour)
|
||||||
{
|
{
|
||||||
if (! read_symbol_stabs_debugging_info (abfd, syms, symcount, dhandle,
|
if (! read_symbol_stabs_debugging_info (abfd, syms, symcount, dhandle,
|
||||||
&found))
|
&found))
|
||||||
return NULL;
|
goto err_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try reading the COFF symbols if we didn't find any stabs in COFF
|
/* Try reading the COFF symbols if we didn't find any stabs in COFF
|
||||||
|
@ -70,7 +71,7 @@ read_debugging_info (bfd *abfd, asymbol **syms, long symcount, bfd_boolean no_me
|
||||||
&& symcount > 0)
|
&& symcount > 0)
|
||||||
{
|
{
|
||||||
if (! parse_coff (abfd, syms, symcount, dhandle))
|
if (! parse_coff (abfd, syms, symcount, dhandle))
|
||||||
return NULL;
|
goto err_exit;
|
||||||
found = TRUE;
|
found = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,6 +80,8 @@ read_debugging_info (bfd *abfd, asymbol **syms, long symcount, bfd_boolean no_me
|
||||||
if (! no_messages)
|
if (! no_messages)
|
||||||
non_fatal (_("%s: no recognized debugging information"),
|
non_fatal (_("%s: no recognized debugging information"),
|
||||||
bfd_get_filename (abfd));
|
bfd_get_filename (abfd));
|
||||||
|
err_exit:
|
||||||
|
free (dhandle);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue