]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* p-lang.c (is_pascal_string_type): Avoid crashes on structures
authorPierre Muller <muller@sourceware.org>
Thu, 14 Oct 2010 15:18:54 +0000 (15:18 +0000)
committerPierre Muller <muller@sourceware.org>
Thu, 14 Oct 2010 15:18:54 +0000 (15:18 +0000)
having fields without names.

gdb/ChangeLog
gdb/p-lang.c

index b5886ddf250f335c9368e46e16ce3f0a3ce8cf4e..d440cb2f39aaf4a4d657ab52e0598f15bbf96d49 100644 (file)
@@ -1,3 +1,8 @@
+2010-10-14  Pierre Muller  <muller@ics.u-strasbg.fr>
+
+       * p-lang.c (is_pascal_string_type): Avoid crashes on structures
+       having fields without names.
+
 2010-10-13  Tom Tromey  <tromey@redhat.com>
 
        * language.h (LA_PRINT_ARRAY_INDEX): Fix argument name.
index 64d2e9f9be6ab66b742b7ae692ba8e9b20f971bc..232ce56fd13399eeb25ed22aca6ce8f4f2f49c45 100644 (file)
@@ -105,8 +105,10 @@ is_pascal_string_type (struct type *type,int *length_pos,
     {
       /* Old Borland type pascal strings from Free Pascal Compiler.  */
       /* Two fields: length and st.  */
-      if (TYPE_NFIELDS (type) == 2 
+      if (TYPE_NFIELDS (type) == 2
+         && TYPE_FIELDS (type) [0].name
           && strcmp (TYPE_FIELDS (type)[0].name, "length") == 0 
+         && TYPE_FIELDS (type) [1].name
           && strcmp (TYPE_FIELDS (type)[1].name, "st") == 0)
         {
           if (length_pos)
@@ -124,7 +126,9 @@ is_pascal_string_type (struct type *type,int *length_pos,
       /* GNU pascal strings.  */
       /* Three fields: Capacity, length and schema$ or _p_schema.  */
       if (TYPE_NFIELDS (type) == 3
+         && TYPE_FIELDS (type) [0].name
           && strcmp (TYPE_FIELDS (type)[0].name, "Capacity") == 0
+         && TYPE_FIELDS (type) [1].name
           && strcmp (TYPE_FIELDS (type)[1].name, "length") == 0)
         {
          if (length_pos)