]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/valgrind/src/valgrind-3.6.0-svn/exp-ptrcheck/tests/justify.c
update
[l4.git] / l4 / pkg / valgrind / src / valgrind-3.6.0-svn / exp-ptrcheck / tests / justify.c
1 #include <stdlib.h>
2 #include <assert.h>
3
4 // This is an example of an error found by Annelid, but not found by
5 // Memcheck -- because the wild read goes past the redzones of the pointer's
6 // block.
7 //
8 // Nb: for Memcheck to not spot this, relies on it putting the 2nd block in
9 // memory after the 1st block.
10
11 int main ( void )
12 {
13    char c __attribute__((unused));
14    char *c0, *c1;
15
16    c0 = malloc(10000);
17    c1 = malloc(10000);
18    assert(c0 && c1);
19
20    c = c0[15000];
21
22    return 0;
23 }