coff-alpha memory leak

Message ID 20191220095226.GF32672@bubble.grove.modra.org
State New
Headers show
Series
  • coff-alpha memory leak
Related show

Commit Message

Alan Modra Dec. 20, 2019, 9:52 a.m.
* coff-alpha.c (alpha_ecoff_read_ar_hdr): Free ar_hdr on error return.


-- 
Alan Modra
Australia Development Lab, IBM

Patch

diff --git a/bfd/coff-alpha.c b/bfd/coff-alpha.c
index d36921bbfe..fe7fcb143d 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);
     }