Skip to content

Commit 56c3499

Browse files
committed
Fix issue with non-null-terminated string in shadow-memory regression tests
1 parent 2cec374 commit 56c3499

File tree

1 file changed

+3
-0
lines changed
  • regression/cbmc-shadow-memory/strdup1

1 file changed

+3
-0
lines changed

regression/cbmc-shadow-memory/strdup1/main.c

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ int main()
88
__CPROVER_field_decl_global("field1", (unsigned __CPROVER_bitvector[2])0);
99

1010
char *s = (char *)malloc(3 * sizeof(char));
11+
// Terminate string so that `strdup` will not call `strlen`
12+
// on a string without a null-terminator.
13+
s[2] = '\0';
1114
assert(__CPROVER_get_field(&s[0], "field1") == 0);
1215
assert(__CPROVER_get_field(&s[1], "field1") == 0);
1316

0 commit comments

Comments
 (0)