From fcc5d04f9264b75241fc50cf655a49c9a7de7d76 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Fri, 20 Dec 2019 10:01:03 +1030 Subject: [PATCH] coff-alpha memory leak * coff-alpha.c (alpha_ecoff_read_ar_hdr): Free ar_hdr on error return. --- bfd/ChangeLog | 4 ++++ bfd/coff-alpha.c | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index dc264de3cc3..c399eac35ac 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,7 @@ +2019-12-20 Alan Modra + + * coff-alpha.c (alpha_ecoff_read_ar_hdr): Free ar_hdr on error return. + 2019-12-18 Alan Modra * coff-rs6000.c (_bfd_xcoff_slurp_armap): Don't overflow when diff --git a/bfd/coff-alpha.c b/bfd/coff-alpha.c index d36921bbfe6..fe7fcb143de 100644 --- a/bfd/coff-alpha.c +++ b/bfd/coff-alpha.c @@ -2026,7 +2026,10 @@ alpha_ecoff_read_ar_hdr (bfd *abfd) if (bfd_seek (abfd, (file_ptr) FILHSZ, SEEK_CUR) != 0 || bfd_bread (ab, (bfd_size_type) 8, abfd) != 8 || bfd_seek (abfd, (file_ptr) (- (FILHSZ + 8)), SEEK_CUR) != 0) - return NULL; + { + free (ret); + return NULL; + } ret->parsed_size = H_GET_64 (abfd, ab); } -- 2.30.2