Skip to content

Commit f250e8b

Browse files
authored
Merge pull request diffblue#4711 from tautschnig/empty-array
Fix segmentation fault with empty array
2 parents 2b30742 + 282f5d5 commit f250e8b

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
int main()
2+
{
3+
int A[0] = {};
4+
int i;
5+
if(A[i] == 1)
6+
__CPROVER_assert(0, "");
7+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
zero-sized.c
3+
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^VERIFICATION FAILED$
7+
--
8+
^warning: ignoring

src/solvers/flattening/boolbv_index.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ bvt boolbvt::convert_index(const index_exprt &expr)
124124
symbol_exprt result(identifier, expr.type());
125125
bv = convert_bv(result);
126126

127+
// return an unconstrained value in case of an empty array (the access is
128+
// necessarily out-of-bounds)
129+
if(!array.has_operands())
130+
return bv;
131+
127132
equal_exprt value_equality(result, array.op0());
128133

129134
binary_relation_exprt lower_bound(

0 commit comments

Comments
 (0)