badrw.c revision e739ac0589b4fb43561f801c4faba8c1b89f8680
1#include <stdlib.h>
2
3int main(void)
4{
5   void* x = malloc(10);
6
7   int   *x4;
8   short *x2;
9   char  *x1;
10   int    y4;
11   short  y2;
12   char   y1;
13
14   x4 = x-4;
15   x2 = x-4;
16   x1 = x-1;
17
18   // Invalid reads and writes of sizes 4, 2, 1
19   y4 = *x4;
20   *x4 = y4;
21
22   y2 = *x2;
23   *x2 = y2;
24
25   y1 = *x1;
26   *x1 = y1;
27
28   return 0;
29}
30