aboutsummaryrefslogtreecommitdiff
path: root/gdb/cp-valprint.c
diff options
context:
space:
mode:
authorSiddhesh Poyarekar <siddhesh@sourceware.org>2012-07-06 05:36:07 +0000
committerSiddhesh Poyarekar <siddhesh@sourceware.org>2012-07-06 05:36:07 +0000
commitd5161074ccccf328ee055eee45b88284939b4fe2 (patch)
treebba19e4695f13d82bc68beda30dc66cefcd2c5fd /gdb/cp-valprint.c
parenta74bc5764616ecf97742696b679b8b917d522dc6 (diff)
downloadgdb-d5161074ccccf328ee055eee45b88284939b4fe2.zip
gdb-d5161074ccccf328ee055eee45b88284939b4fe2.tar.gz
gdb-d5161074ccccf328ee055eee45b88284939b4fe2.tar.bz2
* cp-valprint.c (cp_print_value): Replace potentially unsafe
alloca with xmalloc/xfree.
Diffstat (limited to 'gdb/cp-valprint.c')
-rw-r--r--gdb/cp-valprint.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index 2e3beea..c066aa5 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -554,9 +554,11 @@ cp_print_value (struct type *type, struct type *real_type,
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)
@@ -568,6 +570,7 @@ cp_print_value (struct type *type, struct type *real_type,
boffset = 0;
thistype = baseclass;
base_valaddr = value_contents_for_printing_const (base_val);
+ do_cleanups (back_to);
}
else
{