PR29362, some binutils memory leaks

2022-08-16  Alan Modra  <amodra@gmail.com>
	    Cunlong Li  <shenxiaogll@163.com>

	PR 29362
	* dwarf.c (free_debug_information): New function, extracted..
	(free_debug_memory): ..from here.
	(process_debug_info): Use it when before clearing out unit
	debug_information.  Clear all fields.
	* objcopy.c (delete_symbol_htabs): New function.
	(main): Call it via xatexit.
	(copy_archive): Free "dir".
	* objdump.c (free_debug_section): Free reloc_info.
This commit is contained in:
Alan Modra
2022-08-16 00:16:49 +09:30
parent 105afa7f23
commit 450da4bd38
3 changed files with 43 additions and 28 deletions

View File

@ -1048,6 +1048,20 @@ create_symbol_htabs (void)
redefine_specific_reverse_htab = create_symbol_htab ();
}
static void
delete_symbol_htabs (void)
{
htab_delete (strip_specific_htab);
htab_delete (strip_unneeded_htab);
htab_delete (keep_specific_htab);
htab_delete (localize_specific_htab);
htab_delete (globalize_specific_htab);
htab_delete (keepglobal_specific_htab);
htab_delete (weaken_specific_htab);
htab_delete (redefine_specific_htab);
htab_delete (redefine_specific_reverse_htab);
}
/* Add a symbol to strip_specific_list. */
static void
@ -3736,6 +3750,7 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target,
}
rmdir (dir);
free (dir);
}
static void
@ -6016,6 +6031,7 @@ main (int argc, char *argv[])
}
create_symbol_htabs ();
xatexit (delete_symbol_htabs);
if (argv != NULL)
bfd_set_error_program_name (argv[0]);