Skip to content

Commit

Permalink
Merge pull request #45 from guitargeek/address_deref
Browse files Browse the repository at this point in the history
Avoid `nullptr` dereferencing in CPyCppyy::BindCppObjectNoCast
  • Loading branch information
wlav authored Dec 17, 2024
2 parents 3bb3bff + b49ae84 commit 22e7f1f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
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

0 comments on commit 22e7f1f

Please sign in to comment.