Skip to content

Commit 1590a31

Browse files
authored
Merge pull request #8202 from tautschnig/bugfixes/array_set
array_set: do not fail upon an invalid (void) pointer
2 parents 9c7bccc + 10d5258 commit 1590a31

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
int main()
2+
{
3+
void *p;
4+
__CPROVER_array_set(p, 0);
5+
__CPROVER_assert(
6+
*(char *)p == 0, "should fail: array_set had no effect on invalid object");
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
main.c
3+
4+
^\[main.assertion.1\] line 5 should fail: array_set had no effect on invalid object: FAILURE$
5+
^VERIFICATION FAILED$
6+
^EXIT=10$
7+
^SIGNAL=0$
8+
--
9+
^warning: ignoring
10+
--
11+
An array_set on an invalid pointer must not result in an invariant failure.

src/goto-symex/symex_other.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,11 @@ void goto_symext::symex_other(
183183
// obtain the actual array(s)
184184
process_array_expr(state, array_expr);
185185

186+
// if we dereferenced a void pointer, we may get a zero-sized (failed)
187+
// object -- nothing to be assigned
188+
if(array_expr.type().id() == ID_empty)
189+
return;
190+
186191
// prepare to build the array_of
187192
exprt value = clean_expr(code.op1(), state, false);
188193

0 commit comments

Comments
 (0)