readelf, objdump: fix ctf dict leak

ctf_archive_next returns an opened dict, which must be closed by the caller.

Thanks to Alan Modra for spotting this.

binutils/
	* objdump.c (dump_ctf): Close dict.
	* readelf.c (dump_section_as_ctf): Likewise.
This commit is contained in:
Nick Alcock
2025-02-10 14:40:00 +00:00
parent a3177d19fb
commit bf89fce0cf
2 changed files with 8 additions and 2 deletions

View File

@@ -4940,7 +4940,10 @@ dump_ctf (bfd *abfd, const char *sect_name, const char *parent_name,
printf (_("Contents of CTF section %s:\n"), sanitize_string (sect_name));
while ((fp = ctf_archive_next (ctfa, &i, &name, 0, &err)) != NULL)
dump_ctf_archive_member (fp, name, parent, member++);
{
dump_ctf_archive_member (fp, name, parent, member++);
ctf_dict_close (fp);
}
if (err != ECTF_NEXT_END)
{
dump_ctf_errs (NULL);