From: Jerome Guitton Date: Wed, 4 Feb 2009 17:46:36 +0000 (+0000) Subject: * ada-lang.c (ada_template_to_fixed_record_type_1): Check size X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b53049714948aa8a041abd1c856960b91f94cd1c;p=binutils-gdb.git * ada-lang.c (ada_template_to_fixed_record_type_1): Check size of type to guard against a crash. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 07d85653f4d..04a11fc02d6 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2008-02-04 Jerome Guitton + + * ada-lang.c (ada_template_to_fixed_record_type_1): Check size + of type to guard against a crash. + 2009-02-04 Jerome Guitton * value.c (value_from_contents_and_address): Always return diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 656e771e9b5..2552bff5803 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -6877,7 +6877,15 @@ ada_template_to_fixed_record_type_1 (struct type *type, else if (is_dynamic_field (type, f)) { if (dval0 == NULL) - dval = value_from_contents_and_address (rtype, valaddr, address); + { + /* rtype's length is computed based on the run-time + value of discriminants. If the discriminants are not + initialized, the type size may be completely bogus and + GDB may fail to allocate a value for it. So check the + size first before creating the value. */ + check_size (rtype); + dval = value_from_contents_and_address (rtype, valaddr, address); + } else dval = dval0;