Skip to content

Commit 5da3e1d

Browse files
committed
Leak bug fixed thanks to gideon may <gideon-at-computer.org> for
reporting it. [SVN r18671]
1 parent 1ae85d0 commit 5da3e1d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/object/life_support.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,12 @@ PyObject* make_nurse_and_patient(PyObject* nurse, PyObject* patient)
9999
// We're going to leak this reference, but don't worry; the
100100
// life_support system decrements it when the nurse dies.
101101
PyObject* weakref = PyWeakref_NewRef(nurse, (PyObject*)system);
102+
103+
// weakref has either taken ownership, or we have to release it
104+
// anyway
105+
Py_DECREF(system);
102106
if (!weakref)
103-
{
104-
Py_XDECREF(system);
105107
return 0;
106-
}
107108

108109
system->patient = patient;
109110
Py_XINCREF(patient); // hang on to the patient until death

0 commit comments

Comments
 (0)