Skip to content

Commit

Permalink
Localize variable in hocobj_getattr (result).
Browse files Browse the repository at this point in the history
Check that all paths into the `if` lead to a `return`, i.e. the
previous `result` didn't outlive its new scope.
  • Loading branch information
1uc committed Nov 14, 2024
1 parent 9d72f10 commit 65d8a80
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/nrnpython/nrnpy_hoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1224,8 +1224,8 @@ static PyObject* hocobj_getattr(PyObject* subself, PyObject* pyname) {
return NULL;
}
if (self->ho_) { // use the component fork.
result = hocobj_new(hocobject_type, 0, 0);
PyHocObject* po = (PyHocObject*) result;
PyObject* ret_ho_ = hocobj_new(hocobject_type, 0, 0);
PyHocObject* po = (PyHocObject*) ret_ho_;
po->ho_ = self->ho_;
hoc_obj_ref(po->ho_);
po->sym_ = sym;
Expand Down Expand Up @@ -1265,11 +1265,11 @@ static PyObject* hocobj_getattr(PyObject* subself, PyObject* pyname) {
} else {
po->type_ = PyHoc::HocArray;
}
return result;
return ret_ho_;
}
} else {
po->type_ = PyHoc::HocFunction;
return result;
return ret_ho_;
}
}
// top level interpreter fork
Expand Down

0 comments on commit 65d8a80

Please sign in to comment.