Closed
Description
Required prerequisites
- Make sure you've read the documentation. Your issue may be addressed there.
- Search the issue tracker and Discussions to verify that this hasn't already been reported. +1 or comment there if it has.
- Consider asking first in the Gitter chat room or in a Discussion.
What version (or hash if on master) of pybind11 are you using?
2.10.2
Problem description
Scan highlights possible issue in function clear_patients
in "class.h" file:
I assume the tools expects explicit check before dereferencing:
if (pos != internals.patients.end()) {
// Clearing the patients can cause more Python code to run, which
// can invalidate the iterator. Extract the vector of patients
// from the unordered_map first.
auto patients = std::move(pos->second);
internals.patients.erase(pos);
instance->has_patients = false;
for (PyObject *&patient : patients) {
Py_CLEAR(patient);
}
} else {
assert(pos != internals.patients.end());
}
If such a change is agreeable, I'd be happy to open a PR.
Feel free to resolve this issue if you are against this change and believe this issue is a false positive in the Coverity scan.
Reproducible example code
No response
Is this a regression? Put the last known working version here if it is.
Not a regression