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.
This commit is contained in:
Alan Modra
2025-01-11 15:58:03 +10:30
parent 049467c758
commit 04aeeb697e

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