Will trigger UB if level depth is > 2 billion or in the 2nd case number of lines > 2 billion.
Limit you JS input to 1 GB. I will have more problems in other portions of the stack if I start to receive a 2 GB JSON file over the web.
And if I still want to make it work for > 2GB, I would change all int in the source to 64 bits. Will still crash if input is > 2^64.
What I won't ever do in my code is check for int overflow.
Crashing without a proper error message, leaving the user wondering what happened, is a table stake in C projects, of course. How do you intend to determine the cause of your crashes and write a meaningful error message for the user, in case of too long input when you don't check overflow?
> What I won't ever do in my code is check for int overflow
Amen. Just build with -fno-strict-overflow, my hot take is that should be the default on Linux anyway.