mirror of
https://github.com/nlohmann/json.git
synced 2025-07-28 12:02:00 +03:00
🐛 fixed a bug parsing BSON strings #1320
This commit is contained in:
@ -6532,6 +6532,12 @@ class binary_reader
|
||||
template<typename NumberType>
|
||||
bool get_bson_string(const NumberType len, string_t& result)
|
||||
{
|
||||
if (JSON_UNLIKELY(len < 1))
|
||||
{
|
||||
auto last_token = get_token_string();
|
||||
return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::bson, "string length must be at least 1, is " + std::to_string(len), "string")));
|
||||
}
|
||||
|
||||
return get_string(input_format_t::bson, len - static_cast<NumberType>(1), result) and get() != std::char_traits<char>::eof();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user