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:
Alan Modra 2020-08-14 20:19:39 +09:30
parent fc0efc4bd7
commit 82fcdb3938
3 changed files with 21 additions and 13 deletions

View file

@ -10777,18 +10777,15 @@ free_debug_memory (void)
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].have_frame_base);
}
if (!debug_information [i].max_range_lists)
free (debug_information [i].range_lists);
free (debug_information [i].loc_offsets);
free (debug_information [i].have_frame_base);
}
if (debug_information [i].max_range_lists)
free (debug_information [i].range_lists);
}
free (debug_information);
debug_information = NULL;