[binutils-gdb] Re: dlltool memory leaks

Alan Modra amodra@sourceware.org
Sat Nov 22 07:19:25 GMT 2025


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

commit d37a8694b28d162c5e0ed0edd5948687bc228edc
Author: Alan Modra <amodra@gmail.com>
Date:   Sat Nov 22 16:53:00 2025 +1030

    Re: dlltool memory leaks
    
    I missed one needed strdup of symbol names, needed since the original
    symbol name memory is freed on bfd_close.
    
            PR 33651
            * dlltool.c (scan_filtered_symbols): xstrdup symbol name.

Diff:
---
 binutils/dlltool.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/binutils/dlltool.c b/binutils/dlltool.c
index 99c651f7f9b..8b888fe5a7a 100644
--- a/binutils/dlltool.c
+++ b/binutils/dlltool.c
@@ -1428,6 +1428,7 @@ scan_filtered_symbols (bfd *abfd, void *minisyms, long symcount,
       if (*symbol_name
 	  && *symbol_name == bfd_get_symbol_leading_char (abfd))
 	++symbol_name;
+      symbol_name = xstrdup (symbol_name);
 
       def_exports (symbol_name , 0, -1, 0, 0,
 		   ! (sym->flags & BSF_FUNCTION), 0, NULL);


More information about the Binutils-cvs mailing list