Skip to content

Commit 03026cb

Browse files
Make field_sensitivity ignore negative size arrays
This used to make an invariant fail when the input array had negative size.
1 parent 2af983d commit 03026cb

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/goto-symex/field_sensitivity.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,14 +180,15 @@ exprt field_sensitivityt::get_fields(
180180
#ifdef ENABLE_ARRAY_FIELD_SENSITIVITY
181181
else if(
182182
ssa_expr.type().id() == ID_array &&
183-
to_array_type(ssa_expr.type()).size().id() == ID_constant &&
184-
numeric_cast_v<mp_integer>(
185-
to_constant_expr(to_array_type(ssa_expr.type()).size())) <=
186-
max_field_sensitivity_array_size)
183+
to_array_type(ssa_expr.type()).size().id() == ID_constant)
187184
{
185+
const mp_integer mp_array_size = numeric_cast_v<mp_integer>(
186+
to_constant_expr(to_array_type(ssa_expr.type()).size()));
187+
if(mp_array_size < 0 || mp_array_size > max_field_sensitivity_array_size)
188+
return ssa_expr;
189+
188190
const array_typet &type = to_array_type(ssa_expr.type());
189-
const std::size_t array_size =
190-
numeric_cast_v<std::size_t>(to_constant_expr(type.size()));
191+
const std::size_t array_size = numeric_cast_v<std::size_t>(mp_array_size);
191192

192193
array_exprt result(type);
193194
result.reserve_operands(array_size);

0 commit comments

Comments
 (0)