mirror of
https://github.com/nlohmann/json.git
synced 2026-05-25 15:45:23 +00:00
🐛 fix for #962
Added out_of_range exception for UBJSON containers with sizes that exceed the target container's max_size.
This commit is contained in:
@@ -1246,14 +1246,22 @@ class binary_reader
|
||||
|
||||
if (size_and_type.first != string_t::npos)
|
||||
{
|
||||
if (JSON_UNLIKELY(size_and_type.first > result.max_size()))
|
||||
{
|
||||
JSON_THROW(out_of_range::create(408,
|
||||
"excessive array size: " + std::to_string(size_and_type.first)));
|
||||
}
|
||||
|
||||
if (size_and_type.second != 0)
|
||||
{
|
||||
if (size_and_type.second != 'N')
|
||||
{
|
||||
std::generate_n(std::back_inserter(*result.m_value.array),
|
||||
size_and_type.first, [this, size_and_type]()
|
||||
{
|
||||
return get_ubjson_value(size_and_type.second);
|
||||
});
|
||||
{
|
||||
return get_ubjson_value(size_and_type.second);
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1283,6 +1291,12 @@ class binary_reader
|
||||
|
||||
if (size_and_type.first != string_t::npos)
|
||||
{
|
||||
if (JSON_UNLIKELY(size_and_type.first > result.max_size()))
|
||||
{
|
||||
JSON_THROW(out_of_range::create(408,
|
||||
"excessive object size: " + std::to_string(size_and_type.first)));
|
||||
}
|
||||
|
||||
if (size_and_type.second != 0)
|
||||
{
|
||||
std::generate_n(std::inserter(*result.m_value.object,
|
||||
|
||||
Reference in New Issue
Block a user