aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Smith <dannysmith@gcc.gnu.org>2008-10-03 04:36:36 +0000
committerDanny Smith <dannysmith@gcc.gnu.org>2008-10-03 04:36:36 +0000
commitb268558f8adc09557d9f07818e6f1ac10134b9bf (patch)
tree7ce9af268f8db33625b08a0abf2b0372606543b8
parentfe7b06b7835981e843d480697b1bc072bc2fbd03 (diff)
downloadgcc-b268558f8adc09557d9f07818e6f1ac10134b9bf.zip
gcc-b268558f8adc09557d9f07818e6f1ac10134b9bf.tar.gz
gcc-b268558f8adc09557d9f07818e6f1ac10134b9bf.tar.bz2
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
-rw-r--r--gcc/config/i386/winnt.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/gcc/config/i386/winnt.c b/gcc/config/i386/winnt.c
index 8ef7905..f4356c8 100644
--- a/gcc/config/i386/winnt.c
+++ b/gcc/config/i386/winnt.c
@@ -352,8 +352,16 @@ i386_pe_strip_name_encoding_full (const char *str)
/* Strip trailing "@n". */
p = strchr (name, '@');
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;
}