+2012-07-06  Siddhesh Poyarekar  <siddhesh@redhat.com>
+           Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       * cp-valprint.c (cp_print_value): Replace potentially unsafe
+       alloca with xmalloc/xfree.
+
 2012-07-06  Siddhesh Poyarekar  <siddhesh@redhat.com>
 
        * MAINTAINERS (Write After Approval): Add myself to the list.
 
              if ((boffset + offset) < 0
                  || (boffset + offset) >= TYPE_LENGTH (real_type))
                {
-                 /* FIXME (alloca): unsafe if baseclass is really
-                    really large.  */
-                 gdb_byte *buf = alloca (TYPE_LENGTH (baseclass));
+                 gdb_byte *buf;
+                 struct cleanup *back_to;
+
+                 buf = xmalloc (TYPE_LENGTH (baseclass));
+                 back_to = make_cleanup (xfree, buf);
 
                  if (target_read_memory (address + boffset, buf,
                                          TYPE_LENGTH (baseclass)) != 0)
                  boffset = 0;
                  thistype = baseclass;
                  base_valaddr = value_contents_for_printing_const (base_val);
+                 do_cleanups (back_to);
                }
              else
                {