[binutils-gdb] ld: lang_add_input_file and new_afile leaks

Alan Modra amodra@sourceware.org
Tue Feb 17 00:46:16 GMT 2026


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

commit 776447a4f5e5b30b1dbf1b8db41b0c695a52149d
Author: Alan Modra <amodra@gmail.com>
Date:   Tue Feb 17 11:15:38 2026 +1030

    ld: lang_add_input_file and new_afile leaks
    
    These belong on stat_obstack, where the lang_input_statement is.
    
            * ldlang.c (new_afile): Replace concat with stat_concat.
            (lang_add_input_file): Likewise.

Diff:
---
 ld/ldlang.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/ld/ldlang.c b/ld/ldlang.c
index a8c7854b5f8..5ce8c754eac 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -1232,7 +1232,7 @@ new_afile (const char *name,
 	}
       else
 	p->filename = name;
-      p->local_sym_name = concat ("-l", name, (const char *) NULL);
+      p->local_sym_name = stat_concat ("-l", name, (const char *) NULL);
       p->flags.maybe_archive = true;
       p->flags.real = true;
       p->flags.search_dirs = true;
@@ -1275,9 +1275,9 @@ lang_add_input_file (const char *name,
     {
       lang_input_statement_type *ret;
       char *sysrooted_name
-	= concat (ld_sysroot,
-		  name + (*name == '=' ? 1 : strlen ("$SYSROOT")),
-		  (const char *) NULL);
+	= stat_concat (ld_sysroot,
+		       name + (*name == '=' ? 1 : strlen ("$SYSROOT")),
+		       (const char *) NULL);
 
       /* We've now forcibly prepended the sysroot, making the input
 	 file independent of the context.  Therefore, temporarily


More information about the Binutils-cvs mailing list