blob: 1ac8ad6c69c93aae2107030fa9a31889c9f9cdf7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#include <stdlib.h>
int main(void)
{
// When I had n-u --> u, this gave a false positive... can happen because
// p+up can give n if you are (un)lucky, because the result is close enough
// to zero.
int u[20];
int* p = malloc(sizeof(int) * 100);
p[0] = 0; // ok
int* n = (int*)((long)p + (long)u); // result is n, because near zero!
int* x = (int*)((long)n - (long)u); // x == p
x[0] = 0; // ok, originally caused false pos.
return 0;
}
|