From 006af8691a7ec725ab3b269a99f34862b2d69d55 Mon Sep 17 00:00:00 2001 From: Luis Machado Date: Wed, 15 Dec 2021 12:18:35 -0300 Subject: Fix segfault when creating builtin types Sanity check the existence of a type field before dereferencing it. --- gdb/gdbtypes.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 06f42a10..b83cfb8 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -5732,8 +5732,9 @@ append_composite_type_field_raw (struct type *t, const char *name, f[0].set_type (field); FIELD_NAME (f[0]) = name; - if (field->contains_capability () - || field->code () == TYPE_CODE_CAPABILITY) + if (field != nullptr + && (field->contains_capability () + || field->code () == TYPE_CODE_CAPABILITY)) t->set_contains_capability (true); return f; -- cgit v1.1