summaryrefslogtreecommitdiff
path: root/exp-sgcheck/tests/justify.c
blob: 366c78ba36fea253c3e00dfab8d8aff5af668b1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <stdlib.h>
#include <assert.h>

// This is an example of an error found by Annelid, but not found by
// Memcheck -- because the wild read goes past the redzones of the pointer's
// block.
//
// Nb: for Memcheck to not spot this, relies on it putting the 2nd block in
// memory after the 1st block.

int main ( void )
{
   char c __attribute__((unused));
   char *c0, *c1;

   c0 = malloc(10000);
   c1 = malloc(10000);
   assert(c0 && c1);

   c = c0[15000];

   return 0;
}