From 84d7d92544f4945a556aee9c4f9d30ac27815f09 Mon Sep 17 00:00:00 2001 From: Luis Machado Date: Wed, 15 Dec 2021 12:18:35 -0300 Subject: [PATCH] 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 a22d64ec1a8..d64def3ace5 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -5967,8 +5967,9 @@ append_composite_type_field_raw (struct type *t, const char *name, f[0].set_type (field); f[0].set_name (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; -- 2.47.2