* ada-lang.c (ada_template_to_fixed_record_type_1): Check size
authorJerome Guitton <guitton@adacore.com>
Wed, 4 Feb 2009 17:46:36 +0000 (17:46 +0000)
committerJerome Guitton <guitton@adacore.com>
Wed, 4 Feb 2009 17:46:36 +0000 (17:46 +0000)
of type to guard against a crash.

gdb/ChangeLog
gdb/ada-lang.c

index 07d85653f4db575d7b8c46273fa294a2dbf802af..04a11fc02d632446c3f9701cbfa7341cc4fcd713 100644 (file)
@@ -1,3 +1,8 @@
+2008-02-04  Jerome Guitton  <guitton@adacore.com>
+
+       * ada-lang.c (ada_template_to_fixed_record_type_1): Check size
+       of type to guard against a crash.
+
 2009-02-04  Jerome Guitton  <guitton@adacore.com>
 
        * value.c (value_from_contents_and_address): Always return
index 656e771e9b54c59e9311f8b800609b5153531025..2552bff5803b07cea9780a9f0926bf5ad61b704b 100644 (file)
@@ -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;