From 370426d0da768345fb53683c803d6d5a20558065 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Thu, 16 Jun 2022 14:48:13 +0930 Subject: Always free matching vector from bfd_check_format_matches At least one place calling list_matching_formats failed to free the "matching" vector from bfd_check_format_matches afterwards. Fix that by calling free inside list_matching_formats. binutils/ * bucomm.c (list_matching_formats): Free arg. * addr2line.c (process_file): Adjust to suit. * ar.c (open_inarch, ranlib_touch): Likewise. * coffdump.c (main): Likewise. * nm.c (display_archive, display_file): Likewise. * objcopy.c (copy_file): Likewise. * objdump.c (display_object_bfd): Likewise. * size.c (display_bfd): Likewise. * srconv.c (main): Likewise. ld/ * ldlang.c (load_symbols): Free "matching". --- binutils/nm.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'binutils/nm.c') diff --git a/binutils/nm.c b/binutils/nm.c index 539c568..49726ee 100644 --- a/binutils/nm.c +++ b/binutils/nm.c @@ -1626,10 +1626,7 @@ display_archive (bfd *file) { bfd_nonfatal (bfd_get_filename (arfile)); if (bfd_get_error () == bfd_error_file_ambiguously_recognized) - { - list_matching_formats (matching); - free (matching); - } + list_matching_formats (matching); } if (last_arfile != NULL) @@ -1686,10 +1683,7 @@ display_file (char *filename) { bfd_nonfatal (filename); if (bfd_get_error () == bfd_error_file_ambiguously_recognized) - { - list_matching_formats (matching); - free (matching); - } + list_matching_formats (matching); retval = false; } -- cgit v1.1