Michael Snyder <msnyder@vmware.com> writes:
2011-03-08 Michael Snyder <msnyder@vmware.com>
* objcopy.c (set_pe_subsystem): Keep temp copy of "copy", so we
can free it before returning.
Index: objcopy.c
===================================================================
RCS file: /cvs/src/src/binutils/objcopy.c,v
retrieving revision 1.149
diff -u -p -r1.149 objcopy.c
--- objcopy.c 28 Feb 2011 18:32:51 -0000 1.149
+++ objcopy.c 8 Mar 2011 19:26:36 -0000
@@ -3076,7 +3076,7 @@ strip_main (int argc, char *argv[])
static void
set_pe_subsystem (const char *s)
{
- const char *version, *subsystem;
+ const char *version, *subsystem, *tmp = NULL;
size_t i;
static const struct
{
@@ -3110,6 +3110,7 @@ set_pe_subsystem (const char *s)
int len = version - s;
copy = xstrdup (s);
subsystem = copy;
+ tmp = copy; /* Keep so we can free memory. */
copy[len] = '\0';
version = copy + 1 + len;
pe_major_subsystem_version = strtoul (version, ©, 0);
@@ -3157,6 +3158,7 @@ set_pe_subsystem (const char *s)
pe_section_alignment = PE_DEF_SECTION_ALIGNMENT;
break;
}
+ free (tmp);
}
/* Convert EFI target to PEI target. */
I'd prefer
if (s != subsystem)
free (subsystem);
OK if that works.