From 5c3da5ea2ef28d1f272e737e5165d671149291a0 Mon Sep 17 00:00:00 2001 From: Pierre Muller Date: Thu, 14 Oct 2010 15:18:54 +0000 Subject: [PATCH] * p-lang.c (is_pascal_string_type): Avoid crashes on structures having fields without names. --- gdb/ChangeLog | 5 +++++ gdb/p-lang.c | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index b5886ddf250..d440cb2f39a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2010-10-14 Pierre Muller + + * p-lang.c (is_pascal_string_type): Avoid crashes on structures + having fields without names. + 2010-10-13 Tom Tromey * language.h (LA_PRINT_ARRAY_INDEX): Fix argument name. diff --git a/gdb/p-lang.c b/gdb/p-lang.c index 64d2e9f9be6..232ce56fd13 100644 --- a/gdb/p-lang.c +++ b/gdb/p-lang.c @@ -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) -- 2.30.2