From b268558f8adc09557d9f07818e6f1ac10134b9bf Mon Sep 17 00:00:00 2001 From: Danny Smith Date: Fri, 3 Oct 2008 04:36:36 +0000 Subject: [PATCH] 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 --- gcc/config/i386/winnt.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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; } -- 2.47.3