Skip to content

Segfault fix in cpp_function::dispatcher of an overloaded function with *args/**kwargs #1223

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/pybind11/pybind11.h
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ class cpp_function : public function {
// py::arg().noconvert()). This lets us prefer calls without conversion, with
// conversion as a fallback.
std::vector<function_call> second_pass;
std::vector<object> args_kwargs_keepalive;

// However, if there are no overloads, we can just skip the no-convert pass entirely
const bool overloaded = it != nullptr && it->next != nullptr;
Expand Down Expand Up @@ -586,6 +587,7 @@ class cpp_function : public function {
}
call.args.push_back(extra_args);
call.args_convert.push_back(false);
args_kwargs_keepalive.push_back(extra_args);
}

// 4b. If we have a py::kwargs, pass on any remaining kwargs
Expand All @@ -594,6 +596,7 @@ class cpp_function : public function {
kwargs = dict(); // If we didn't get one, send an empty one
call.args.push_back(kwargs);
call.args_convert.push_back(false);
args_kwargs_keepalive.push_back(kwargs);
}

// 5. Put everything in a vector. Not technically step 5, we've been building it
Expand Down