Skip to content

Commit 3a4ebeb

Browse files
author
Daniel Kroening
committed
use preconditions in the library
1 parent f443b18 commit 3a4ebeb

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/ansi-c/library/stdlib.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,13 @@ inline void free(void *ptr)
145145
{
146146
__CPROVER_HIDE:;
147147
// If ptr is NULL, no operation is performed.
148+
__CPROVER_precondition(ptr==0 || __CPROVER_DYNAMIC_OBJECT(ptr),
149+
"free argument must be dynamic object");
150+
__CPROVER_precondition(ptr==0 || __CPROVER_POINTER_OFFSET(ptr)==0,
151+
"free argument has offset zero");
152+
148153
if(ptr!=0)
149154
{
150-
// is it dynamic?
151-
__CPROVER_assert(__CPROVER_DYNAMIC_OBJECT(ptr),
152-
"free argument is dynamic object");
153-
__CPROVER_assert(__CPROVER_POINTER_OFFSET(ptr)==0,
154-
"free argument has offset zero");
155-
156155
// catch double free
157156
if(__CPROVER_deallocated==ptr)
158157
__CPROVER_assert(0, "double free");

0 commit comments

Comments
 (0)