From b71d4fa7c35c1918e96bc3c297f940b5c1624e21 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Wed, 15 Apr 2020 16:40:54 +0930 Subject: [PATCH] readelf: zero static vars after freeing 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. --- binutils/ChangeLog | 5 +++++ binutils/readelf.c | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/binutils/ChangeLog b/binutils/ChangeLog index e6c9c2ea8ae..a30d38d4aea 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,8 @@ +2020-04-15 Alan Modra + + * readelf.c (process_symbol_table): Zero gnubuckets, gnuchains + etc. after freeing. + 2020-04-15 Alan Modra * readelf.c (get_group_flags): Translate text. diff --git a/binutils/readelf.c b/binutils/readelf.c index fb6f801b9fa..80af9a242ac 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; } -- 2.30.2