Merge pull request #2203 from t-b/use-unsigned-indizies-for-array-index-in-json-pointer

Use unsigned indizies for array index in json pointer
This commit is contained in:
Niels Lohmann 2020-06-23 09:16:01 +02:00 committed by GitHub
commit 4bfe4add20
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 73 additions and 34 deletions

View file

@ -8207,7 +8207,7 @@ class basic_json
else
{
const auto idx = json_pointer::array_index(last_path);
if (JSON_HEDLEY_UNLIKELY(static_cast<size_type>(idx) > parent.size()))
if (JSON_HEDLEY_UNLIKELY(idx > parent.size()))
{
// avoid undefined behavior
JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range"));
@ -8250,7 +8250,7 @@ class basic_json
else if (parent.is_array())
{
// note erase performs range check
parent.erase(static_cast<size_type>(json_pointer::array_index(last_path)));
parent.erase(json_pointer::array_index(last_path));
}
};