File tree 4 files changed +45
-0
lines changed
malloc-too-large-just-about 4 files changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include <assert.h>
2
+ #include <stdint.h>
3
+ #include <stdlib.h>
4
+
5
+ int main ()
6
+ {
7
+ size_t pointer_width = sizeof (void * ) * 8 ;
8
+ size_t object_bits = 8 ; // by default
9
+ size_t cbmc_max_alloc_size = (size_t )1 << (pointer_width - object_bits );
10
+ int * p2 = malloc (cbmc_max_alloc_size - 1 ); // try to allocate exactly the max
11
+
12
+ return 0 ;
13
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+ --malloc-max-check
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^\[malloc.max_allocation_check.\d+\] line \d+ malloc_size < 2 \^ \(pointer_width - object_size\) in ALLOCATE\(malloc_size, 0 != 0\): SUCCESS$
7
+ ^VERIFICATION SUCCESSFUL$
8
+ --
9
+ ^warning: ignoring
Original file line number Diff line number Diff line change
1
+ #include <assert.h>
2
+ #include <stdint.h>
3
+ #include <stdlib.h>
4
+
5
+ int main ()
6
+ {
7
+ size_t pointer_width = sizeof (void * ) * 8 ;
8
+ size_t object_bits = 8 ; // by default
9
+ size_t cbmc_max_alloc_size = (size_t )1 << (pointer_width - object_bits );
10
+ // try to allocate the smallest violating amount
11
+ int * p3 = malloc (cbmc_max_alloc_size );
12
+
13
+ return 0 ;
14
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+ --malloc-max-check
4
+ ^EXIT=10$
5
+ ^SIGNAL=0$
6
+ ^\[malloc.max_allocation_check.\d+\] line \d+ malloc_size < 2 \^ \(pointer_width - object_size\) in ALLOCATE\(malloc_size, 0 != 0\): FAILURE$
7
+ ^VERIFICATION FAILED$
8
+ --
9
+ ^warning: ignoring
You can’t perform that action at this time.
0 commit comments