]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix ICE when using -gcodeview with empty struct
authorMark Harmstone <mark@harmstone.com>
Fri, 26 Jul 2024 19:46:33 +0000 (20:46 +0100)
committerMark Harmstone <mark@harmstone.com>
Thu, 1 Aug 2024 01:36:54 +0000 (02:36 +0100)
Empty structs result in empty LF_FIELDLIST types, which are valid, but
we weren't accounting for this and assuming they had to contain
subtypes.

gcc/
* dwarf2codeview.cc (get_type_num_struct): Fix NULL pointer dereference.

gcc/dwarf2codeview.cc

index b16c6960f63e8a3761248729e92ed9e9d7c069c2..470cbae711037a04df44d093c2f5676a1395722e 100644 (file)
@@ -2858,8 +2858,11 @@ get_type_num_struct (dw_die_ref type, bool in_struct, bool *is_fwd_ref)
       ct2 = ct->next;
       ct->next = NULL;
 
-      if (ct->lf_fieldlist.last_subtype->kind == LF_INDEX)
-       ct->lf_fieldlist.last_subtype->lf_index.type_num = last_type;
+      if (ct->lf_fieldlist.last_subtype
+         && ct->lf_fieldlist.last_subtype->kind == LF_INDEX)
+       {
+         ct->lf_fieldlist.last_subtype->lf_index.type_num = last_type;
+       }
 
       add_custom_type (ct);
       last_type = ct->num;