mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-24 14:15:11 +00:00
fix: added check on iterator end position (#5129)
* Added check on iterator end position * Always use assert without conditional check * Addressing code review comments * style: pre-commit fixes * Remove assert and throw * Changed style slightly --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
ce08e37042
commit
a5b9e50f68
@ -388,7 +388,11 @@ inline void clear_patients(PyObject *self) {
|
|||||||
auto *instance = reinterpret_cast<detail::instance *>(self);
|
auto *instance = reinterpret_cast<detail::instance *>(self);
|
||||||
auto &internals = get_internals();
|
auto &internals = get_internals();
|
||||||
auto pos = internals.patients.find(self);
|
auto pos = internals.patients.find(self);
|
||||||
assert(pos != internals.patients.end());
|
|
||||||
|
if (pos == internals.patients.end()) {
|
||||||
|
pybind11_fail("FATAL: Internal consistency check failed: Invalid clear_patients() call.");
|
||||||
|
}
|
||||||
|
|
||||||
// Clearing the patients can cause more Python code to run, which
|
// Clearing the patients can cause more Python code to run, which
|
||||||
// can invalidate the iterator. Extract the vector of patients
|
// can invalidate the iterator. Extract the vector of patients
|
||||||
// from the unordered_map first.
|
// from the unordered_map first.
|
||||||
|
Loading…
Reference in New Issue
Block a user