File tree 2 files changed +24
-0
lines changed 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,12 @@ inline void *__new(__typeof__(sizeof(int)) malloc_size)
8
8
// This just does memory allocation.
9
9
__CPROVER_HIDE :;
10
10
void * res ;
11
+ // ensure that all bytes in the allocated memory can be addressed
12
+ // using our object:offset encoding as specified in
13
+ // flattening/pointer_logic.h; also avoid sign-extension issues
14
+ // for 32-bit systems that yields a maximum allocation of 2^23-1,
15
+ // i.e., just under 8MB
16
+ __CPROVER_assume (malloc_size < (1UL << ((sizeof (char * ) - 1 ) * 8 - 1 )));
11
17
res = __CPROVER_allocate (malloc_size , 0 );
12
18
13
19
// ensure it's not recorded as deallocated
@@ -35,6 +41,12 @@ inline void *__new_array(__CPROVER_size_t count, __CPROVER_size_t size)
35
41
// The constructor call is done by the front-end.
36
42
// This just does memory allocation.
37
43
__CPROVER_HIDE :;
44
+ // ensure that all bytes in the allocated memory can be addressed
45
+ // using our object:offset encoding as specified in
46
+ // flattening/pointer_logic.h; also avoid sign-extension issues
47
+ // for 32-bit systems that yields a maximum allocation of 2^23-1,
48
+ // i.e., just under 8MB
49
+ __CPROVER_assume (size * count < (1UL << ((sizeof (char * ) - 1 ) * 8 - 1 )));
38
50
void * res ;
39
51
res = __CPROVER_allocate (size * count , 0 );
40
52
Original file line number Diff line number Diff line change @@ -106,6 +106,12 @@ inline void *malloc(__CPROVER_size_t malloc_size)
106
106
// realistically, malloc may return NULL,
107
107
// and __CPROVER_allocate doesn't, but no one cares
108
108
__CPROVER_HIDE :;
109
+ // ensure that all bytes in the allocated memory can be addressed
110
+ // using our object:offset encoding as specified in
111
+ // flattening/pointer_logic.h; also avoid sign-extension issues
112
+ // for 32-bit systems that yields a maximum allocation of 2^23-1,
113
+ // i.e., just under 8MB
114
+ __CPROVER_assume (malloc_size < (1UL << ((sizeof (char * ) - 1 ) * 8 - 1 )));
109
115
void * malloc_res ;
110
116
malloc_res = __CPROVER_allocate (malloc_size , 0 );
111
117
@@ -132,6 +138,12 @@ __CPROVER_bool __VERIFIER_nondet___CPROVER_bool();
132
138
inline void * __builtin_alloca (__CPROVER_size_t alloca_size )
133
139
{
134
140
__CPROVER_HIDE :;
141
+ // ensure that all bytes in the allocated memory can be addressed
142
+ // using our object:offset encoding as specified in
143
+ // flattening/pointer_logic.h; also avoid sign-extension issues
144
+ // for 32-bit systems that yields a maximum allocation of 2^23-1,
145
+ // i.e., just under 8MB
146
+ __CPROVER_assume (alloca_size < (1UL << ((sizeof (char * ) - 1 ) * 8 - 1 )));
135
147
void * res ;
136
148
res = __CPROVER_allocate (alloca_size , 0 );
137
149
You can’t perform that action at this time.
0 commit comments