readelf memory leak in process_mips_specific

Message ID 20200324025001.GV4583@bubble.grove.modra.org
State New
Headers show
Series
  • readelf memory leak in process_mips_specific
Related show

Commit Message

Stefan Schulze Frielinghaus via Binutils March 24, 2020, 2:50 a.m.
* readelf.c (process_mips_specific): Free iconf on error path.


-- 
Alan Modra
Australia Development Lab, IBM

Patch

diff --git a/binutils/readelf.c b/binutils/readelf.c
index 61f0617683..1f0f49222f 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -17074,7 +17074,10 @@  process_mips_specific (Filedata * filedata)
 	    get_data (NULL, filedata, conflicts_offset,
 		      sizeof (*econf32), conflictsno, _("conflict"));
 	  if (!econf32)
-	    return FALSE;
+	    {
+	      free (iconf);
+	      return FALSE;
+	    }
 
 	  for (cnt = 0; cnt < conflictsno; ++cnt)
 	    iconf[cnt] = BYTE_GET (econf32[cnt]);
@@ -17089,7 +17092,10 @@  process_mips_specific (Filedata * filedata)
 	    get_data (NULL, filedata, conflicts_offset,
 		      sizeof (*econf64), conflictsno, _("conflict"));
 	  if (!econf64)
-	    return FALSE;
+	    {
+	      free (iconf);
+	      return FALSE;
+	    }
 
 	  for (cnt = 0; cnt < conflictsno; ++cnt)
 	    iconf[cnt] = BYTE_GET (econf64[cnt]);