Skip to content

Commit

Permalink
Fix leak in nrncore_arg.
Browse files Browse the repository at this point in the history
Because `PyObject_GetAttrString` returns a new reference [1], we're
responsible for calling DECREF on the `callable`.

[1]: https://docs.python.org/3/c-api/object.html#c.PyObject_GetAttrString
  • Loading branch information
1uc committed Nov 15, 2024
1 parent cdd3fae commit 041cd1e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/nrnpython/nrnpy_hoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3335,7 +3335,7 @@ static char* nrncore_arg(double tstop) {
if (modules) {
PyObject* module = PyDict_GetItemString(modules, "neuron.coreneuron");
if (module) {
PyObject* callable = PyObject_GetAttrString(module, "nrncore_arg");
auto callable = nb::steal(PyObject_GetAttrString(module, "nrncore_arg"));
if (callable) {
PyObject* ts = Py_BuildValue("(d)", tstop);
if (ts) {
Expand Down

0 comments on commit 041cd1e

Please sign in to comment.