Skip to content

Commit e6d9b4c

Browse files
committed
Overload Signature: Potential Nullptr Deref
Fix a potential nullptr in error handling. The `it` variable is already checked in the `try` block for non-nullptr and might therefore be `nullptr` in this branch as well. Found with coverity in a downstream project.
1 parent 085a294 commit e6d9b4c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

include/pybind11/pybind11.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,10 @@ class cpp_function : public function {
763763
} else if (!result) {
764764
std::string msg = "Unable to convert function return value to a "
765765
"Python type! The signature was\n\t";
766-
msg += it->signature;
766+
if (it == nullptr)
767+
msg += "not found (nullptr).";
768+
else
769+
msg += it->signature;
767770
append_note_if_missing_header_is_suspected(msg);
768771
PyErr_SetString(PyExc_TypeError, msg.c_str());
769772
return nullptr;

0 commit comments

Comments
 (0)