From 8906dd2d89fb5d06abb45cd43aed5ee518c126d0 Mon Sep 17 00:00:00 2001 From: Daniel Parker Date: Fri, 16 Aug 2024 11:01:19 -0400 Subject: [PATCH] reduce parser limits --- include/jsoncons/json_parser.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/jsoncons/json_parser.hpp b/include/jsoncons/json_parser.hpp index d52ce89dd..a7efe13b0 100644 --- a/include/jsoncons/json_parser.hpp +++ b/include/jsoncons/json_parser.hpp @@ -106,8 +106,8 @@ class basic_json_parser : public ser_context using char_allocator_type = typename std::allocator_traits:: template rebind_alloc; using parse_state_allocator_type = typename std::allocator_traits:: template rebind_alloc; - static constexpr std::size_t initial_string_buffer_capacity_ = 1024; - static constexpr int default_initial_stack_capacity_ = 100; + static constexpr std::size_t initial_string_buffer_capacity = 256; + static constexpr int default_initial_stack_capacity = 66; basic_json_decode_options options_; @@ -175,9 +175,9 @@ class basic_json_parser : public ser_context string_buffer_(temp_alloc), state_stack_(temp_alloc) { - string_buffer_.reserve(initial_string_buffer_capacity_); + 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()+2) <= default_initial_stack_capacity ? (options.max_nesting_depth()+2) : default_initial_stack_capacity; state_stack_.reserve(initial_stack_capacity ); push_state(json_parse_state::root);