Skip to content

Commit c8eeff1

Browse files
committed
[cppyy] Fix memory leak in TemplateProxy::Instantiate()
The `PyObject * exact` is set to be the return value of `PyObject_GetItem()`, which returns a new reference that needs to be dereferenced when not used anymore. Otherwise, memory will leak. This could be a problem in code that uses lots of template instantiations.
1 parent 78a6f80 commit c8eeff1

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

bindings/pyroot/cppyy/CPyCppyy/src/TemplateProxy.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ PyObject* TemplateProxy::Instantiate(const std::string& fname,
296296
}
297297

298298
// cleanup
299+
Py_XDECREF(exact);
299300
Py_DECREF(pyresname);
300301
Py_DECREF(pycachename);
301302

0 commit comments

Comments
 (0)