• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include "pub_tool_basics.h"
4 
main(void)5 int main(void)
6 {
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;
20 }
21