readelf: zero static vars after freeing

Alan Modra amodra@gmail.com
Wed Apr 15 07:32:17 GMT 2020


When readelf is processing more than one file, static bss vars won't
start out as zero for the second file unless they are cleared.

	* readelf.c (process_symbol_table): Zero gnubuckets, gnuchains
	etc. after freeing.

diff --git a/binutils/readelf.c b/binutils/readelf.c
index fb6f801b9f..80af9a242a 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -12260,16 +12260,24 @@ process_symbol_table (Filedata * filedata)
       free (lengths);
     }
   free (gnubuckets);
+  gnubuckets = NULL;
   free (gnuchains);
+  gnuchains = NULL;
   free (mipsxlat);
+  mipsxlat = NULL;
   return TRUE;
 
  err_out:
   free (gnubuckets);
+  gnubuckets = NULL;
   free (gnuchains);
+  gnuchains = NULL;
   free (mipsxlat);
+  mipsxlat = NULL;
   free (buckets);
+  buckets = NULL;
   free (chains);
+  chains = NULL;
   return FALSE;
 }
 

-- 
Alan Modra
Australia Development Lab, IBM


More information about the Binutils mailing list