Handle invalid struct members

When something goes wrong when parsing a struct member, e.g. the type does
not exist, a nullptr is added to the struct member list. This will cause a
crash when iterating over the list.

E.g.

```
struct packed {
  logc x;
} s;
```

Add a check so that nullptr members are not added to the list.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2022-01-09 21:32:49 +01:00
parent 8b1240f7cf
commit 5bfc8a42eb
1 changed files with 2 additions and 2 deletions

View File

@ -3036,12 +3036,12 @@ struct_data_type
struct_union_member_list
: struct_union_member_list struct_union_member
{ std::list<struct_member_t*>*tmp = $1;
tmp->push_back($2);
if ($2) tmp->push_back($2);
$$ = tmp;
}
| struct_union_member
{ std::list<struct_member_t*>*tmp = new std::list<struct_member_t*>;
tmp->push_back($1);
if ($1) tmp->push_back($1);
$$ = tmp;
}
;