28 lines · c
1#include <stdint.h>2#include <stdio.h>3 4uint32_t5recurse_crash (uint32_t depth)6{7 if (depth > 0)8 return recurse_crash (depth - 1);9 return 0;10}11 12int13main (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 we17 // eventually crash the program by overflowing the stack18 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}