@@ -13,9 +13,9 @@ inline void *__new(__typeof__(sizeof(int)) malloc_size)
13
13
// ensure it's not recorded as deallocated
14
14
__CPROVER_deallocated = (res == __CPROVER_deallocated )?0 :__CPROVER_deallocated ;
15
15
16
- // non-derministically record the object size for bounds checking
16
+ // non-deterministically record the object for delete/delete[] checking
17
17
__CPROVER_bool record_malloc = __VERIFIER_nondet___CPROVER_bool ();
18
- __CPROVER_malloc_object = record_malloc ? res : __CPROVER_malloc_object ;
18
+ __CPROVER_new_object = record_malloc ? res : __CPROVER_new_object ;
19
19
__CPROVER_malloc_is_new_array = record_malloc ?0 :__CPROVER_malloc_is_new_array ;
20
20
21
21
// detect memory leaks
@@ -40,9 +40,9 @@ inline void *__new_array(__CPROVER_size_t count, __CPROVER_size_t size)
40
40
// ensure it's not recorded as deallocated
41
41
__CPROVER_deallocated = (res == __CPROVER_deallocated )?0 :__CPROVER_deallocated ;
42
42
43
- // non-deterministically record the object size for bounds checking
43
+ // non-deterministically record the object for delete/delete[] checking
44
44
__CPROVER_bool record_malloc = __VERIFIER_nondet___CPROVER_bool ();
45
- __CPROVER_malloc_object = record_malloc ? res : __CPROVER_malloc_object ;
45
+ __CPROVER_new_object = record_malloc ? res : __CPROVER_new_object ;
46
46
__CPROVER_malloc_is_new_array = record_malloc ?1 :__CPROVER_malloc_is_new_array ;
47
47
48
48
// detect memory leaks
@@ -80,10 +80,9 @@ inline void __delete(void *ptr)
80
80
__CPROVER_precondition (ptr == 0 || __CPROVER_deallocated != ptr , "double delete" );
81
81
82
82
// catch people who call delete for objects allocated with new[]
83
- __CPROVER_precondition (ptr == 0 ||
84
- __CPROVER_malloc_object != ptr ||
85
- !__CPROVER_malloc_is_new_array ,
86
- "delete of array object" );
83
+ __CPROVER_precondition (
84
+ ptr == 0 || __CPROVER_new_object != ptr || !__CPROVER_malloc_is_new_array ,
85
+ "delete of array object" );
87
86
88
87
// If ptr is NULL, no operation is performed.
89
88
// This is a requirement by the standard, not generosity!
@@ -120,10 +119,9 @@ inline void __delete_array(void *ptr)
120
119
"double delete" );
121
120
122
121
// catch people who call delete[] for objects allocated with new
123
- __CPROVER_precondition (ptr == 0 ||
124
- __CPROVER_malloc_object != ptr ||
125
- __CPROVER_malloc_is_new_array ,
126
- "delete[] of non-array object" );
122
+ __CPROVER_precondition (
123
+ ptr == 0 || __CPROVER_new_object != ptr || __CPROVER_malloc_is_new_array ,
124
+ "delete[] of non-array object" );
127
125
128
126
if (ptr != 0 )
129
127
{
0 commit comments