1 | #include <stdint.h> |
2 | #include <stdio.h> |
3 | |
4 | uint32_t |
5 | recurse_crash (uint32_t depth) |
6 | { |
7 | if (depth > 0) |
8 | return recurse_crash (depth: depth - 1); |
9 | return 0; |
10 | } |
11 | |
12 | int |
13 | main (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 | } |