File tree Expand file tree Collapse file tree 4 files changed +33
-16
lines changed
Expand file tree Collapse file tree 4 files changed +33
-16
lines changed Original file line number Diff line number Diff line change 11CORE
22main.c
3- --pointer-check --bounds-check
3+ --pointer-check --bounds-check --malloc-may-fail --malloc-fail-null
44VERIFICATION SUCCESSFUL
55^EXIT=0$
66^SIGNAL=0$
77--
8- ^\*\*\*\* WARNING: no body for function posix_memalign
8+ ^warning: ignoring
Original file line number Diff line number Diff line change 1+ #include <stdlib.h>
2+ #include <string.h>
3+
4+ int main ()
5+ {
6+ size_t size = 4 ;
7+ size_t page_size = 4096 ;
8+ void * src = "testing" ;
9+ void * dest ;
10+ posix_memalign (& dest , page_size , size );
11+ memcpy (dest , src , size );
12+ return 0 ;
13+ }
Original file line number Diff line number Diff line change 1+ CORE
2+ main.c
3+ --pointer-check --bounds-check --malloc-may-fail --malloc-fail-null
4+ ^EXIT=10$
5+ ^SIGNAL=0$
6+ ^VERIFICATION FAILED$
7+ \[main.precondition_instance.1\] .* memcpy src/dst overlap: FAILURE
8+ \[main.precondition_instance.3\] .* memcpy destination region writeable: FAILURE
9+ \*\* 2 of 14 failed
10+ --
11+ ^warning: ignoring
Original file line number Diff line number Diff line change @@ -527,20 +527,13 @@ __CPROVER_HIDE:;
527527 // As _mid_memalign simplifies for alignment <= MALLOC_ALIGNMENT
528528 // to a malloc call, it should be sound, if we do it too.
529529
530- // The original posix_memalign check on the pointer is:
531-
532- // void *tmp = malloc(size);
533- // if(tmp != NULL){
534- // *ptr = tmp;
535- // return 0;
536- // }
537- // return ENOMEM;
538-
539- // As _CPROVER_allocate used in malloc never returns null,
540- // this check is not applicable and can be simplified:
541-
542- * ptr = malloc (size );
543- return 0 ;
530+ void * tmp = malloc (size );
531+ if (tmp != (void * )0 )
532+ {
533+ * ptr = tmp ;
534+ return 0 ;
535+ }
536+ return ENOMEM ;
544537}
545538
546539/* FUNCTION: random */
You can’t perform that action at this time.
0 commit comments