diff options
| -rw-r--r-- | gcc/config/i386/winnt.c | 12 |
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; } |
