1
0
mirror of https://github.com/nlohmann/json.git synced 2025-07-31 10:24:23 +03:00

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
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));
}
};