Skip to content

Prevent abort() call while parsing an input strings with too deep nestings - #1710

Open
smallSwed wants to merge 1 commit into
open-source-parsers:masterfrom
smallSwed:master
Open

Prevent abort() call while parsing an input strings with too deep nestings#1710
smallSwed wants to merge 1 commit into
open-source-parsers:masterfrom
smallSwed:master

Conversation

@smallSwed

Copy link
Copy Markdown

When JSON_USE_EXCEPTION set 0 jsoncpp should not abort when the input string contains object/array which is exceeds the stackLimit.
The caller unable to validate that the input string exceeds the nesting stackLimit without parsing the json, so abort is a bad response for this case.
When the JSON_USE_EXCEPTION is 1 then the caller can catch the thrown exception and handle the issue how they want it.

With this change I intend to make the non-exception variant case fail gracefully too and handle-able.

…h too deep nested objects/arrays when JSON_USE_EXCEPTION=0
@smallSwed

smallSwed commented Jul 30, 2026

Copy link
Copy Markdown
Author

I wasn't sure to how to rework the error recovery, but maybe in this case the parser may better to skip the whole recovering all together.
I think that could be achieved by the code chage when the stackLimit exceeded:

    ...
    current_ = end_; // short circuit the parsing to prevent error recovery
    return addError(
    ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant