Jan Kratochvil 92b52c5
http://sourceware.org/ml/gdb-cvs/2012-09/msg00068.html
Jan Kratochvil 92b52c5
Jan Kratochvil 92b52c5
### src/gdb/ChangeLog	2012/09/14 12:10:21	1.14659
Jan Kratochvil 92b52c5
### src/gdb/ChangeLog	2012/09/14 12:46:55	1.14660
Jan Kratochvil 92b52c5
## -1,3 +1,8 @@
Jan Kratochvil 92b52c5
+2012-09-14  Siddhesh Poyarekar  <siddhesh@redhat.com>
Jan Kratochvil 92b52c5
+
Jan Kratochvil 92b52c5
+	* valarith.c (value_concat): Replace unsafe ALLOCA with
Jan Kratochvil 92b52c5
+	XMALLOC/XFREE.
Jan Kratochvil 92b52c5
+
Jan Kratochvil 92b52c5
 2012-09-14  Pedro Alves  <palves@redhat.com>
Jan Kratochvil 92b52c5
 
Jan Kratochvil 92b52c5
 	* gdb.1 (SEE ALSO): Expand pointer to GDB's Texinfo manual.
Jan Kratochvil 92b52c5
Index: gdb-7.5.0.20120926/gdb/valarith.c
Jan Kratochvil 92b52c5
===================================================================
Jan Kratochvil 92b52c5
--- gdb-7.5.0.20120926.orig/gdb/valarith.c	2012-11-07 22:00:41.000000000 +0100
Jan Kratochvil 92b52c5
+++ gdb-7.5.0.20120926/gdb/valarith.c	2012-11-07 22:02:18.661767281 +0100
Jan Kratochvil 92b52c5
@@ -716,9 +716,12 @@ value_concat (struct value *arg1, struct
Jan Kratochvil 92b52c5
       if (TYPE_CODE (type2) == TYPE_CODE_STRING
Jan Kratochvil 92b52c5
 	  || TYPE_CODE (type2) == TYPE_CODE_CHAR)
Jan Kratochvil 92b52c5
 	{
Jan Kratochvil 92b52c5
+	  struct cleanup *back_to;
Jan Kratochvil 92b52c5
+
Jan Kratochvil 92b52c5
 	  count = longest_to_int (value_as_long (inval1));
Jan Kratochvil 92b52c5
 	  inval2len = TYPE_LENGTH (type2);
Jan Kratochvil 92b52c5
-	  ptr = (char *) alloca (count * inval2len);
Jan Kratochvil 92b52c5
+	  ptr = (char *) xmalloc (count * inval2len);
Jan Kratochvil 92b52c5
+	  back_to = make_cleanup (xfree, ptr);
Jan Kratochvil 92b52c5
 	  if (TYPE_CODE (type2) == TYPE_CODE_CHAR)
Jan Kratochvil 92b52c5
 	    {
Jan Kratochvil 92b52c5
 	      char_type = type2;
Jan Kratochvil 92b52c5
@@ -741,6 +744,7 @@ value_concat (struct value *arg1, struct
Jan Kratochvil 92b52c5
 		}
Jan Kratochvil 92b52c5
 	    }
Jan Kratochvil 92b52c5
 	  outval = value_string (ptr, count * inval2len, char_type);
Jan Kratochvil 92b52c5
+	  do_cleanups (back_to);
Jan Kratochvil 92b52c5
 	}
Jan Kratochvil 92b52c5
       else if (TYPE_CODE (type2) == TYPE_CODE_BITSTRING
Jan Kratochvil 92b52c5
 	       || TYPE_CODE (type2) == TYPE_CODE_BOOL)
Jan Kratochvil 92b52c5
@@ -755,6 +759,8 @@ value_concat (struct value *arg1, struct
Jan Kratochvil 92b52c5
   else if (TYPE_CODE (type1) == TYPE_CODE_STRING
Jan Kratochvil 92b52c5
 	   || TYPE_CODE (type1) == TYPE_CODE_CHAR)
Jan Kratochvil 92b52c5
     {
Jan Kratochvil 92b52c5
+      struct cleanup *back_to;
Jan Kratochvil 92b52c5
+
Jan Kratochvil 92b52c5
       /* We have two character strings to concatenate.  */
Jan Kratochvil 92b52c5
       if (TYPE_CODE (type2) != TYPE_CODE_STRING
Jan Kratochvil 92b52c5
 	  && TYPE_CODE (type2) != TYPE_CODE_CHAR)
Jan Kratochvil 92b52c5
@@ -763,7 +769,8 @@ value_concat (struct value *arg1, struct
Jan Kratochvil 92b52c5
 	}
Jan Kratochvil 92b52c5
       inval1len = TYPE_LENGTH (type1);
Jan Kratochvil 92b52c5
       inval2len = TYPE_LENGTH (type2);
Jan Kratochvil 92b52c5
-      ptr = (char *) alloca (inval1len + inval2len);
Jan Kratochvil 92b52c5
+      ptr = (char *) xmalloc (inval1len + inval2len);
Jan Kratochvil 92b52c5
+      back_to = make_cleanup (xfree, ptr);
Jan Kratochvil 92b52c5
       if (TYPE_CODE (type1) == TYPE_CODE_CHAR)
Jan Kratochvil 92b52c5
 	{
Jan Kratochvil 92b52c5
 	  char_type = type1;
Jan Kratochvil 92b52c5
@@ -786,6 +793,7 @@ value_concat (struct value *arg1, struct
Jan Kratochvil 92b52c5
 	  memcpy (ptr + inval1len, value_contents (inval2), inval2len);
Jan Kratochvil 92b52c5
 	}
Jan Kratochvil 92b52c5
       outval = value_string (ptr, inval1len + inval2len, char_type);
Jan Kratochvil 92b52c5
+      do_cleanups (back_to);
Jan Kratochvil 92b52c5
     }
Jan Kratochvil 92b52c5
   else if (TYPE_CODE (type1) == TYPE_CODE_BITSTRING
Jan Kratochvil 92b52c5
 	   || TYPE_CODE (type1) == TYPE_CODE_BOOL)