Skip to content

Commit

Permalink
Add a test case with implicit dereferences
Browse files Browse the repository at this point in the history
  • Loading branch information
mrstanb committed Aug 31, 2023
1 parent 293d3e7 commit e4b349a
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/regression/77-mem-oob/05-oob-implicit-deref.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// PARAM: --set ana.activated[+] memOutOfBounds --enable ana.int.interval
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

int main(int argc, char const *argv[]) {
int *ptr = malloc(4 * sizeof(int));

// Both lines below are considered derefs => no need to warn, since ptr is pointing within its bounds
memset(ptr, 0, 4 * sizeof(int)); //NOWARN
printf("%p", (void *) ptr); //NOWARN
ptr = ptr + 10; // ptr no longer points within its allocated bounds

// Each of both lines below should now receive a WARN
memset(ptr, 0, 4 * sizeof(int)); //WARN
printf("%p", (void *) ptr); //WARN

return 0;
}

0 comments on commit e4b349a

Please sign in to comment.