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:
@ -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));
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user