When the depth is both larger than the string length (guaranteeing depth limit won't be hit) and larger than a cutoff such as 100000, ignore it and use a smaller byte length value such as
- the existing parser depth, if that is
>= the string length
- 100000, if that's sufficient
- strlen * 2 (or the requested depth), if that's sufficient (adding extra space to make reallocations less frequent if the application calls this again with the same depth but varying string sizes)
The fact that memory is allocated for depth is different from json_decode, so users might not expect the high memory usage when attempting to avoid depth errors
When the depth is both larger than the string length (guaranteeing depth limit won't be hit) and larger than a cutoff such as 100000, ignore it and use a smaller byte length value such as
>=the string lengthThe fact that memory is allocated for depth is different from json_decode, so users might not expect the high memory usage when attempting to avoid depth errors