drd/tests/sem_open: Change the semaphore name (#331839)
[valgrind.git] / memcheck / tests / calloc-overflow.c
blobc4ab6ebf8dfee6f3a17ece7a38f0d66ee4f1ce12
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include "pub_tool_basics.h"
5 int main(void)
7 // The n*size multiplication overflows in this example. The only sensible
8 // thing to do is return NULL, but old versions of Valgrind didn't (they
9 // often ground to a halt trying to allocate an enormous (but not as
10 // enormous as asked-for!) block. See bug 149878.
11 int* x;
12 #if VG_WORDSIZE == 8
13 size_t szB = 0x1000000010000001ULL;
14 #else
15 size_t szB = 0x10000001UL;
16 #endif
17 x = calloc(szB, 0x10);
18 fprintf(stderr, "x = %#lx\n", (long)x);
19 return 0;