From: Alan Modra Date: Sat, 11 Jan 2025 05:28:03 +0000 (+1030) Subject: bfd_get_unique_section_name leak X-Git-Tag: binutils-2_44~122 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=04aeeb697e70806ac5ffb941a0359f125b2f71cf;p=thirdparty%2Fbinutils-gdb.git 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 --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);