[binutils-gdb] bfd_get_unique_section_name leak

Alan Modra amodra@sourceware.org
Wed Jan 15 12:08:29 GMT 2025


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

commit 04aeeb697e70806ac5ffb941a0359f125b2f71cf
Author: Alan Modra <amodra@gmail.com>
Date:   Sat Jan 11 15:58:03 2025 +1030

    bfd_get_unique_section_name leak
    
    The name returned by this function is used in asection->name, so
    needs to persist until a bfd is closed.
    
            * section.c (bfd_get_unique_section_name): Return an alloc'd
            string.

Diff:
---
 bfd/section.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bfd/section.c b/bfd/section.c
index e7674c9dc1a..ffd28911297 100644
--- a/bfd/section.c
+++ b/bfd/section.c
@@ -1063,7 +1063,7 @@ bfd_get_unique_section_name (bfd *abfd, const char *templat, int *count)
   char *sname;
 
   len = strlen (templat);
-  sname = (char *) bfd_malloc (len + 8);
+  sname = bfd_alloc (abfd, len + 8);
   if (sname == NULL)
     return NULL;
   memcpy (sname, templat, len);


More information about the Binutils-cvs mailing list