bfd_check_format memory leak
authorAlan Modra <amodra@gmail.com>
Thu, 19 Dec 2019 23:33:30 +0000 (10:03 +1030)
committerAlan Modra <amodra@gmail.com>
Fri, 20 Dec 2019 03:06:06 +0000 (13:36 +1030)
* format.c (bfd_check_format_matches): Free matching_vector when
not returning matching target strings.

bfd/ChangeLog
bfd/format.c

index c399eac35ac2753a481fef6ae93e118377a40bbc..61d19911599b318a2831d2be7f4a4e4efd2284dd 100644 (file)
@@ -1,3 +1,8 @@
+2019-12-20  Alan Modra  <amodra@gmail.com>
+
+       * format.c (bfd_check_format_matches): Free matching_vector when
+       not returning matching target strings.
+
 2019-12-20  Alan Modra  <amodra@gmail.com>
 
        * coff-alpha.c (alpha_ecoff_read_ar_hdr): Free ar_hdr on error return.
index 1d1363d18403cef706ec1a81f164c5b6521dd20f..17b48556a9a10422fd704fe8699eb44907c2f33d 100644 (file)
@@ -513,6 +513,8 @@ bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching)
          *(const char **) &matching_vector[match_count] = name;
        }
     }
+  else if (matching_vector)
+    free (matching_vector);
   return FALSE;
 }