]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gas include_dirs memory leak
authorAlan Modra <amodra@gmail.com>
Wed, 1 Jan 2025 12:08:44 +0000 (22:38 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 1 Jan 2025 12:08:44 +0000 (22:38 +1030)
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.

gas/config/tc-tic54x.c
gas/read.c

index 7de8b8cf4c84db252997203558e9ad41f4e51458..b0d98f1ab4a00d35df2e22dd47ba67fa9358f634 100644 (file)
@@ -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
        {
index 3d4dff821b64d296065365585f9e7869eb1fd90a..94e12549d4ff73d5cea3900b1910ab69401275bc 100644 (file)
@@ -330,6 +330,7 @@ read_end (void)
   _obstack_free (&cond_obstack, NULL);
   free (current_name);
   free (current_label);
+  free (include_dirs);
 }
 \f
 #ifndef TC_ADDRESS_BYTES