]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
winnt.c (i386_pe_strip_name_encoding_full): Add a null terminator to the stripped...
authorDanny Smith <dannysmith@gcc.gnu.org>
Fri, 3 Oct 2008 04:36:36 +0000 (04:36 +0000)
committerDanny Smith <dannysmith@gcc.gnu.org>
Fri, 3 Oct 2008 04:36:36 +0000 (04:36 +0000)
* config/i386/winnt.c (i386_pe_strip_name_encoding_full):
Add a null terminator to the stripped name.

From-SVN: r140849

gcc/config/i386/winnt.c

index 8ef79058a7d8442ae7fe1d0900df58bbbfebf8f1..f4356c8bb94754b19cb52251710154714201f2a7 100644 (file)
@@ -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;
 }