From 9d78076ef8ef07890ad89c1122bdf49932a979a5 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Fri, 20 Dec 2019 10:03:30 +1030 Subject: [PATCH] bfd_check_format memory leak * format.c (bfd_check_format_matches): Free matching_vector when not returning matching target strings. --- bfd/ChangeLog | 5 +++++ bfd/format.c | 2 ++ 2 files changed, 7 insertions(+) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index c399eac35ac..61d19911599 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2019-12-20 Alan Modra + + * format.c (bfd_check_format_matches): Free matching_vector when + not returning matching target strings. + 2019-12-20 Alan Modra * coff-alpha.c (alpha_ecoff_read_ar_hdr): Free ar_hdr on error return. diff --git a/bfd/format.c b/bfd/format.c index 1d1363d1840..17b48556a9a 100644 --- a/bfd/format.c +++ b/bfd/format.c @@ -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; } -- 2.30.2