File tree 3 files changed +10
-0
lines changed 3 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -155,6 +155,10 @@ void ansi_c_internal_additions(std::string &code)
155
155
" void *" CPROVER_PREFIX " allocate("
156
156
CPROVER_PREFIX " size_t size, " CPROVER_PREFIX " bool zero);\n "
157
157
" const void *" CPROVER_PREFIX " alloca_object = 0;\n "
158
+ CPROVER_PREFIX " size_t " CPROVER_PREFIX " pointer_width=" +
159
+ std::to_string (config.ansi_c .pointer_width )+" ;\n "
160
+ CPROVER_PREFIX " size_t " CPROVER_PREFIX " object_bits=" +
161
+ std::to_string (config.bv_encoding .object_bits )+" ;\n "
158
162
159
163
// this is ANSI-C
160
164
" extern " CPROVER_PREFIX " thread_local const char __func__["
Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ extern const void *__CPROVER_malloc_object;
16
16
extern __CPROVER_size_t __CPROVER_malloc_size ;
17
17
extern _Bool __CPROVER_malloc_is_new_array ;
18
18
extern const void * __CPROVER_memory_leak ;
19
+ extern __CPROVER_size_t __CPROVER_pointer_width ;
20
+ extern __CPROVER_size_t __CPROVER_object_bits ;
19
21
20
22
void __CPROVER_assume (__CPROVER_bool assumption ) __attribute__((__noreturn__ ));
21
23
void __CPROVER_assert (__CPROVER_bool assertion , const char * description );
Original file line number Diff line number Diff line change @@ -115,6 +115,10 @@ inline void *malloc(__CPROVER_size_t malloc_size)
115
115
// realistically, malloc may return NULL,
116
116
// and __CPROVER_allocate doesn't, but no one cares
117
117
__CPROVER_HIDE :;
118
+
119
+ if (malloc_size >= ((__CPROVER_size_t )1 << (__CPROVER_pointer_width - __CPROVER_object_bits )))
120
+ return (void * )0 ;
121
+
118
122
void * malloc_res ;
119
123
malloc_res = __CPROVER_allocate (malloc_size , 0 );
120
124
You can’t perform that action at this time.
0 commit comments