sewardj | 024598e | 2008-09-18 14:43:05 +0000 | [diff] [blame] | 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 | { |
bart | f976f6c | 2011-04-03 17:42:19 +0000 | [diff] [blame] | 13 | char c __attribute__((unused)); |
sewardj | 024598e | 2008-09-18 14:43:05 +0000 | [diff] [blame] | 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 | } |