ndarray can only be used with array containers, discard if used in object

This commit is contained in:
Qianqian Fang 2022-03-01 22:51:16 -05:00
parent f38a67e3c2
commit e7ae719b9a
3 changed files with 13 additions and 0 deletions

View File

@ -2500,6 +2500,11 @@ class binary_reader
return false;
}
if (input_format == input_format_t::bjdata && size_and_type.first != string_t::npos && size_and_type.first >= (1ull << (sizeof(std::size_t) * 8 - 1)))
{
return false;
}
string_t key;
if (size_and_type.first != string_t::npos)
{

View File

@ -10876,6 +10876,11 @@ class binary_reader
return false;
}
if (input_format == input_format_t::bjdata && size_and_type.first != string_t::npos && size_and_type.first >= (1ull << (sizeof(std::size_t) * 8 - 1)))
{
return false;
}
string_t key;
if (size_and_type.first != string_t::npos)
{

View File

@ -2830,6 +2830,9 @@ TEST_CASE("BJData")
CHECK_THROWS_AS(_ = json::from_bjdata(vST2), json::parse_error&);
CHECK_THROWS_WITH(_ = json::from_bjdata(vST2), "[json.exception.parse_error.110] parse error at byte 8: syntax error while parsing BJData value: unexpected end of input");
CHECK(json::from_bjdata(vST2, true, false).is_discarded());
std::vector<uint8_t> vO = {'{', '#', '[', 'i', 2, 'i', 1, ']', 'i', 1, 'a', 'i', 1, 'i', 1, 'b', 'i', 2};
CHECK(json::from_bjdata(vO, true, false).is_discarded());
}
}