blob: 1159669ebf152f3d4cde2ea9ef2a8e74a7dcd827 [file] [log] [blame]
Greg Claytonda4b9872011-01-07 22:10:25 +00001#include <stdint.h>
2#include <stdio.h>
3
4uint32_t
5recurse_crash (uint32_t depth)
6{
7 if (depth > 0)
8 return recurse_crash (depth - 1);
9 return 0;
10}
11
12int
13main (int argc, char const *argv[])
14{
15 // If we have more than one argument, then it should a depth to recurse to.
16 // If we have just the program name as an argument, use UINT32_MAX so we
17 // eventually crash the program by overflowing the stack
18 uint32_t depth = UINT32_MAX;
19 if (argc > 1)
20 {
21 char *end = NULL;
22 depth = strtoul (argv[1], &end, 0);
23 if (end == NULL || *end != '\0')
24 depth = UINT32_MAX;
25 }
26 recurse_crash (depth);
27 return 0;
28}