Commit b268558f by Danny Smith

winnt.c (i386_pe_strip_name_encoding_full): Add a null terminator to the stripped name.

	* config/i386/winnt.c (i386_pe_strip_name_encoding_full):
	Add a null terminator to the stripped name.

From-SVN: r140849
parent fe7b06b7
...@@ -352,8 +352,16 @@ i386_pe_strip_name_encoding_full (const char *str) ...@@ -352,8 +352,16 @@ i386_pe_strip_name_encoding_full (const char *str)
/* Strip trailing "@n". */ /* Strip trailing "@n". */
p = strchr (name, '@'); p = strchr (name, '@');
if (p) if (p)
return ggc_alloc_string (name, p - name); {
/* We need to replace the suffix with a null terminator.
Do that before using ggc_alloc_string to allocate the
const char *. */
size_t len = p - name;
char *newname = XALLOCAVEC (char, len + 1);
memcpy (newname, name, len);
newname [len] = 0;
return ggc_alloc_string (newname, len);
}
return name; return name;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment