From d84ac2a1485ba3f4414d9195d4273ea6bd572e83 Mon Sep 17 00:00:00 2001 From: Florian Albrechtskirchinger Date: Wed, 8 Jun 2022 09:20:18 +0200 Subject: [PATCH] Use value_in_range_of trait --- include/nlohmann/detail/input/binary_reader.hpp | 4 ++-- single_include/nlohmann/json.hpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/nlohmann/detail/input/binary_reader.hpp b/include/nlohmann/detail/input/binary_reader.hpp index 5fe19b810..619fe1a4b 100644 --- a/include/nlohmann/detail/input/binary_reader.hpp +++ b/include/nlohmann/detail/input/binary_reader.hpp @@ -2079,7 +2079,7 @@ class binary_reader return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, exception_message(input_format, "count in an optimized container must be positive", "size"), nullptr)); } - if (number > std::numeric_limits::max()) + if (!value_in_range_of(number)) { return sax->parse_error(chars_read, get_token_string(), parse_error::create(408, chars_read, exception_message(input_format, "integer value overflow", "size"), nullptr)); @@ -2129,7 +2129,7 @@ class binary_reader { return false; } - if (number > std::numeric_limits::max()) + if (!value_in_range_of(number)) { return sax->parse_error(chars_read, get_token_string(), parse_error::create(408, chars_read, exception_message(input_format, "integer value overflow", "size"), nullptr)); diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 281f66d88..1314ee7fb 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -10764,7 +10764,7 @@ class binary_reader return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, exception_message(input_format, "count in an optimized container must be positive", "size"), nullptr)); } - if (number > std::numeric_limits::max()) + if (!value_in_range_of(number)) { return sax->parse_error(chars_read, get_token_string(), parse_error::create(408, chars_read, exception_message(input_format, "integer value overflow", "size"), nullptr)); @@ -10814,7 +10814,7 @@ class binary_reader { return false; } - if (number > std::numeric_limits::max()) + if (!value_in_range_of(number)) { return sax->parse_error(chars_read, get_token_string(), parse_error::create(408, chars_read, exception_message(input_format, "integer value overflow", "size"), nullptr));