I noticed a bad test in dwarf2/read.c:anonymous_struct_prefix:
attr = dw2_linkage_name_attr (die, cu);
const char *attr_name = attr->as_string ();
if (attr == NULL || attr_name == NULL)
return NULL;
Here, if attr==NULL, this will crash before the test can be executed.
This patch fixes the problem by hoisting the test. I'm checking this
in as obvious.
return NULL;
attr = dw2_linkage_name_attr (die, cu);
+ if (attr == nullptr)
+ return nullptr;
const char *attr_name = attr->as_string ();
- if (attr == NULL || attr_name == NULL)
- return NULL;
+ if (attr_name == nullptr)
+ return nullptr;
/* dwarf2_name had to be already called. */
gdb_assert (attr->canonical_string_p ());