]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Re: asan: more readelf leaks
authorAlan Modra <amodra@gmail.com>
Sat, 14 Mar 2020 08:28:11 +0000 (18:58 +1030)
committerAlan Modra <amodra@gmail.com>
Sat, 14 Mar 2020 09:53:52 +0000 (20:23 +1030)
In git commit fd486f32d15e I put some static variables used by
get_symbol_for_build_attribute in a file scope ba_cache struct.  This
was to prevent leaks in get_symbol_for_build_attribute, and to tidy up
before readelf exited.  The patch wasn't quite right though.  When
readelf processes more than one file it was possible to double free
arrays allocated in get_symbol_for_build_attribute.

* readelf.c (process_file): Clean ba_cache.

binutils/ChangeLog
binutils/readelf.c

index 5101b8c99120e1635f180f6f50910cdb87fc9d62..5f8af9468040748412ee8b925cd1dc167637e661 100644 (file)
@@ -1,3 +1,7 @@
+2020-03-14  Alan Modra  <amodra@gmail.com>
+
+       * readelf.c (process_file): Clean ba_cache.
+
 2020-03-14  Alan Modra  <amodra@gmail.com>
 
        * elfcomm.h (setup_archive): Update prototype.
index 0f8a0809c556e99d80a836a08f406369878b15fa..49eb20f28c34f0ef971fc12b3b1e4643b36cd147 100644 (file)
@@ -20571,7 +20571,9 @@ process_file (char * file_name)
   free (filedata);
 
   free (ba_cache.strtab);
+  ba_cache.strtab = NULL;
   free (ba_cache.symtab);
+  ba_cache.symtab = NULL;
   ba_cache.filedata = NULL;
 
   return ret;