Skip to content

Commit 4234d72

Browse files
committed
value sets: do not try to access components of an empty struct/union
This avoids a segmentation fault while running on c/ldv-linux-4.2-rc1/linux-4.2-rc1.tar.xz-32_7a-drivers--staging--lustre--lustre--mdc--mdc.ko-entry_point.cil.out.i with options --pointer-check --bounds-check --unwind 2. This benchmark includes the empty `union __anonunion_u_rpc_386`. While the patch does address the problem on this benchmark, I failed to come up with a small regression test.
1 parent 813a0ad commit 4234d72

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/pointer-analysis/value_set.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -425,14 +425,17 @@ optionalt<irep_idt> value_sett::get_index_of_symbol(
425425
const struct_union_typet &struct_union_type =
426426
to_struct_union_type(followed_type);
427427

428-
const irep_idt &first_component_name =
429-
struct_union_type.components().front().get_name();
430-
431-
index =
432-
id2string(identifier) + "." + id2string(first_component_name) + suffix;
433-
entry = find_entry(index);
434-
if(entry)
435-
return std::move(index);
428+
if(!struct_union_type.components().empty())
429+
{
430+
const irep_idt &first_component_name =
431+
struct_union_type.components().front().get_name();
432+
433+
index =
434+
id2string(identifier) + "." + id2string(first_component_name) + suffix;
435+
entry = find_entry(index);
436+
if(entry)
437+
return std::move(index);
438+
}
436439
}
437440

438441
// not found? try without suffix

0 commit comments

Comments
 (0)