unsigned char* init() { unsigned long buffer_size; if(buffer_size!=1) return 0; unsigned char* buffer=__CPROVER_malloc(buffer_size); __CPROVER_assert(buffer!=0, "malloc did not return NULL"); buffer[0]=10; return buffer; }
unsigned char* init() { unsigned long size; if (size!=1) return 0; assert(sizeof(unsigned char)==1); unsigned char* buffer=__CPROVER_malloc(size); assert(buffer!=0); buffer[0]=0; return buffer; }
inline void *malloc(__CPROVER_size_t malloc_size) { // realistically, malloc may return NULL, // and __CPROVER_malloc doesn't, but no one cares __CPROVER_HIDE:; void *res; res=__CPROVER_malloc(malloc_size); // make sure it's not recorded as deallocated __CPROVER_deallocated=(res==__CPROVER_deallocated)?0:__CPROVER_deallocated; // record the object size for non-determistic bounds checking _Bool record_malloc; __CPROVER_malloc_object=record_malloc?res:__CPROVER_malloc_object; __CPROVER_malloc_size=record_malloc?malloc_size:__CPROVER_malloc_size; __CPROVER_malloc_is_new_array=record_malloc?0:__CPROVER_malloc_is_new_array; return res; }
inline char *getenv(const char *name) { __CPROVER_HIDE:; #ifdef __CPROVER_STRING_ABSTRACTION __CPROVER_assert(__CPROVER_is_zero_string(name), "zero-termination of argument of getenv"); #endif _Bool found; if(!found) return 0; char *buffer; __CPROVER_size_t buf_size; __CPROVER_assume(buf_size>=1); buffer=(char *)__CPROVER_malloc(buf_size); buffer[buf_size-1]=0; return buffer; }
inline void *__new_array(__CPROVER_size_t count, __CPROVER_size_t size) { // The constructor call is done by the front-end. // This just does memory allocation. __CPROVER_HIDE:; void *res; res=__CPROVER_malloc(size*count); // ensure it's not recorded as deallocated __CPROVER_deallocated=(res==__CPROVER_deallocated)?0:__CPROVER_deallocated; // non-deterministically record the object size for bounds checking __CPROVER_bool record_malloc=__VERIFIER_nondet___CPROVER_bool(); __CPROVER_malloc_object=record_malloc?res:__CPROVER_malloc_object; __CPROVER_malloc_size=record_malloc?size*count:__CPROVER_malloc_size; __CPROVER_malloc_is_new_array=record_malloc?1:__CPROVER_malloc_is_new_array; // detect memory leaks __CPROVER_bool record_may_leak=__VERIFIER_nondet___CPROVER_bool(); __CPROVER_memory_leak=record_may_leak?res:__CPROVER_memory_leak; return res; }