@@ -67,6 +67,12 @@ inline void *malloc(__CPROVER_size_t malloc_size);
67
67
inline void * calloc (__CPROVER_size_t nmemb , __CPROVER_size_t size )
68
68
{
69
69
__CPROVER_HIDE :;
70
+ // ensure that all bytes in the allocated memory can be addressed
71
+ // using our object:offset encoding as specified in
72
+ // flattening/pointer_logic.h; also avoid sign-extension issues
73
+ // for 32-bit systems that yields a maximum allocation of 2^23-1,
74
+ // i.e., just under 8MB
75
+ __CPROVER_assume (nmemb * size < (1ULL <<((sizeof (char * )-1 )* 8 - 1 )));
70
76
void * res ;
71
77
res = malloc (nmemb * size );
72
78
#ifdef __CPROVER_STRING_ABSTRACTION
@@ -92,6 +98,12 @@ inline void *malloc(__CPROVER_size_t malloc_size)
92
98
// realistically, malloc may return NULL,
93
99
// and __CPROVER_malloc doesn't, but no one cares
94
100
__CPROVER_HIDE :;
101
+ // ensure that all bytes in the allocated memory can be addressed
102
+ // using our object:offset encoding as specified in
103
+ // flattening/pointer_logic.h; also avoid sign-extension issues
104
+ // for 32-bit systems that yields a maximum allocation of 2^23-1,
105
+ // i.e., just under 8MB
106
+ __CPROVER_assume (malloc_size < (1ULL <<((sizeof (char * )-1 )* 8 - 1 )));
95
107
void * malloc_res ;
96
108
malloc_res = __CPROVER_malloc (malloc_size );
97
109
@@ -116,6 +128,12 @@ inline void *malloc(__CPROVER_size_t malloc_size)
116
128
inline void * __builtin_alloca (__CPROVER_size_t alloca_size )
117
129
{
118
130
__CPROVER_HIDE :;
131
+ // ensure that all bytes in the allocated memory can be addressed
132
+ // using our object:offset encoding as specified in
133
+ // flattening/pointer_logic.h; also avoid sign-extension issues
134
+ // for 32-bit systems that yields a maximum allocation of 2^23-1,
135
+ // i.e., just under 8MB
136
+ __CPROVER_assume (alloca_size < (1ULL <<((sizeof (char * )-1 )* 8 - 1 )));
119
137
void * res ;
120
138
res = __CPROVER_malloc (alloca_size );
121
139
0 commit comments