]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* config/mmix/mmix.c (mmix_encode_section_info): Use alloca to
authorhp <hp@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 22 Nov 2007 07:34:10 +0000 (07:34 +0000)
committerhp <hp@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 22 Nov 2007 07:34:10 +0000 (07:34 +0000)
avoid writing into string allocated by ggc_alloc_string.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@130342 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/mmix/mmix.c

index b128a5af979490a98c63b8dda3dd96bd872df115..ac51ad5489950d08b8dd73616e7e9e171a9d1b30 100644 (file)
@@ -1,3 +1,8 @@
+2007-11-22  Tom Tromey  <tromey@redhat.com>
+
+       * 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  <kkojima@gcc.gnu.org>
 
        PR target/34155
index a55b0dcc7f33e97d9e6082bd26fcb156bf5235de..271b3d21a6a0920e5c02f3f738437667d8dbc39f 100644 (file)
@@ -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