Skip to content
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

Avoid nullptr dereferencing in CPyCppyy::BindCppObjectNoCast #45

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 0 additions & 2 deletions src/CPPMethod.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -611,8 +611,6 @@ PyObject* CPyCppyy::CPPMethod::GetArgDefault(int iarg, bool silent)
PyObject* gdct = *dctptr;
PyObject* scope = nullptr;

std::string possible_scope = defvalue.substr(0, defvalue.rfind('('));

if (defvalue.rfind('(') != std::string::npos) { // constructor-style call
// try to tickle scope creation, just in case, first look in the scope where
// the function lives, then in the global scope
Expand Down
2 changes: 1 addition & 1 deletion src/ProxyWrappers.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ PyObject* CPyCppyy::BindCppObjectNoCast(Cppyy::TCppObject_t address,

bool noReg = flags & (CPPInstance::kNoMemReg|CPPInstance::kNoWrapConv);
bool isRef = flags & CPPInstance::kIsReference;
void* r_address = isRef ? *(void**)address : address;
void* r_address = isRef ? (address ? *(void**)address : nullptr) : address;

// check whether the object to be bound is a smart pointer that needs embedding
PyObject* smart_type = (!(flags & CPPInstance::kNoWrapConv) && \
Expand Down