From: Danny Smith Date: Fri, 3 Oct 2008 04:36:36 +0000 (+0000) Subject: winnt.c (i386_pe_strip_name_encoding_full): Add a null terminator to the stripped... X-Git-Tag: releases/gcc-4.4.0~2182 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b268558f8adc09557d9f07818e6f1ac10134b9bf;p=thirdparty%2Fgcc.git 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 --- diff --git a/gcc/config/i386/winnt.c b/gcc/config/i386/winnt.c index 8ef79058a7d8..f4356c8bb947 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; }