]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
bfd_get_unique_section_name leak
authorAlan Modra <amodra@gmail.com>
Sat, 11 Jan 2025 05:28:03 +0000 (15:58 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 15 Jan 2025 12:07:17 +0000 (22:37 +1030)
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.

bfd/section.c

index e7674c9dc1a8cdb1cd60eca5ff859748af49ea26..ffd2891129781a77848d3e47f537819407e61f4d 100644 (file)
@@ -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);