Skip to content

Commit

Permalink
Fix off-by-one error in parser buffer size
Browse files Browse the repository at this point in the history
When parsing a value with the maximum number of digits the last digit
will be truncated and the exponent increased instead.
This change allows to parse e.g. `<UINT64_MAX>e0` correctly.
  • Loading branch information
Flamefire committed Dec 28, 2024
1 parent cbf501f commit 73eb4f8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/boost/charconv/detail/parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ inline from_chars_result parser(const char* first, const char* last, bool& sign,
}

// Next we get the significand
constexpr std::size_t significand_buffer_size = limits<Unsigned_Integer>::max_chars10 - 1; // Base 10 or 16
constexpr std::size_t significand_buffer_size = limits<Unsigned_Integer>::max_chars10; // Base 10 or 16
char significand_buffer[significand_buffer_size] {};
std::size_t i = 0;
std::size_t dot_position = 0;
Expand Down

0 comments on commit 73eb4f8

Please sign in to comment.