Skip to content

Commit

Permalink
Merge pull request #542 from PragmaTwice/patch-1
Browse files Browse the repository at this point in the history
Avoid integer overflow UB in basic_json_parser
  • Loading branch information
danielaparker authored Oct 7, 2024
2 parents fffa250 + 5a0ec6e commit a500279
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/jsoncons/json_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class basic_json_parser : public ser_context
{
string_buffer_.reserve(initial_string_buffer_capacity);

std::size_t initial_stack_capacity = (options.max_nesting_depth()+2) <= default_initial_stack_capacity ? (options.max_nesting_depth()+2) : default_initial_stack_capacity;
std::size_t initial_stack_capacity = options.max_nesting_depth() <= (default_initial_stack_capacity-2) ? (options.max_nesting_depth()+2) : default_initial_stack_capacity;
state_stack_.reserve(initial_stack_capacity );
push_state(json_parse_state::root);

Expand Down

0 comments on commit a500279

Please sign in to comment.