dlltool memory leaks

Alan Modra amodra@gmail.com
Sat Nov 22 07:18:29 GMT 2025


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 --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);

-- 
Alan Modra


More information about the Binutils mailing list