[binutils-gdb] gas include_dirs memory leak

Alan Modra amodra@sourceware.org
Wed Jan 1 12:45:31 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b492153908463bd351eaa2cf3802117ce9e7c479

commit b492153908463bd351eaa2cf3802117ce9e7c479
Author: Alan Modra <amodra@gmail.com>
Date:   Wed Jan 1 22:38:44 2025 +1030

    gas include_dirs memory leak
    
    This is the first of a series of patches aimed at making it possible
    to configure with CFLAGS="-g -O2 -fsanitize=address,undefined" and run
    the binutils and gas testsuite on x86_64-linux without using
    ASAN_OPTIONS=detect_leaks=0.  ie. the patch series is aimed at fixing
    common gas, ar, objcopy, objdump, and readelf leaks.
    
            * config/tc-tic54x.c (md_begin): Make use of notes_strdup rather
            than xstrdup to copy entries added to include_dirs.
            * read.c (read_end): Free include_dirs array.

Diff:
---
 gas/config/tc-tic54x.c | 2 +-
 gas/read.c             | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/gas/config/tc-tic54x.c b/gas/config/tc-tic54x.c
index 7de8b8cf4c8..b0d98f1ab4a 100644
--- a/gas/config/tc-tic54x.c
+++ b/gas/config/tc-tic54x.c
@@ -2990,7 +2990,7 @@ md_begin (void)
   /* Look for A_DIR and add it to the include list.  */
   if (A_DIR != NULL)
     {
-      char *tmp = xstrdup (A_DIR);
+      char *tmp = notes_strdup (A_DIR);
 
       do
 	{
diff --git a/gas/read.c b/gas/read.c
index 3d4dff821b6..94e12549d4f 100644
--- a/gas/read.c
+++ b/gas/read.c
@@ -330,6 +330,7 @@ read_end (void)
   _obstack_free (&cond_obstack, NULL);
   free (current_name);
   free (current_label);
+  free (include_dirs);
 }
 

 #ifndef TC_ADDRESS_BYTES


More information about the Binutils-cvs mailing list