From d26d1cea50055e4bae9192bef57bc4d5277ddd4f Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Thu, 22 Nov 2007 07:34:10 +0000 Subject: mmix.c (mmix_encode_section_info): Use alloca to avoid writing into string allocated by ggc_alloc_string. * config/mmix/mmix.c (mmix_encode_section_info): Use alloca to avoid writing into string allocated by ggc_alloc_string. From-SVN: r130342 --- gcc/ChangeLog | 5 +++++ gcc/config/mmix/mmix.c | 9 +++------ 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'gcc') diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b128a5a..ac51ad5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2007-11-22 Tom Tromey + + * config/mmix/mmix.c (mmix_encode_section_info): Use alloca to + avoid writing into string allocated by ggc_alloc_string. + 2007-11-21 Kaz Kojima PR target/34155 diff --git a/gcc/config/mmix/mmix.c b/gcc/config/mmix/mmix.c index a55b0dc..271b3d2 100644 --- a/gcc/config/mmix/mmix.c +++ b/gcc/config/mmix/mmix.c @@ -1158,14 +1158,11 @@ mmix_encode_section_info (tree decl, rtx rtl, int first) const char *str = XSTR (XEXP (rtl, 0), 0); int len = strlen (str); - char *newstr; - - /* Why is the return type of ggc_alloc_string const? */ - newstr = CONST_CAST (char *, ggc_alloc_string ("", len + 1)); - + char *newstr = alloca (len + 2); + newstr[0] = '@'; strcpy (newstr + 1, str); *newstr = '@'; - XSTR (XEXP (rtl, 0), 0) = newstr; + XSTR (XEXP (rtl, 0), 0) = ggc_alloc_string (newstr, len + 1); } /* Set SYMBOL_REF_FLAG for things that we want to access with GETA. We -- cgit v1.1