fix memory leak

This commit is contained in:
Nikolay Kim 2017-07-19 06:35:59 -07:00
parent c6067b90c1
commit 5559dbb9ed
2 changed files with 2 additions and 0 deletions

View File

@ -206,6 +206,7 @@ impl PyObject {
let ptr = ffi::PyObject_GetAttr(self.as_ptr(), name);
let result = PyObject::from_borrowed_ptr_or_err(
py, ffi::PyObject_Call(ptr, t.as_ptr(), kwargs.as_ptr()));
ffi::Py_DECREF(ptr);
py.release(t);
result
})

View File

@ -267,6 +267,7 @@ impl<T> ObjectProtocol for T where T: PyObjectWithToken + ToPyPointer {
let ptr = ffi::PyObject_GetAttr(self.as_ptr(), name);
let result = self.py().cast_from_borrowed_ptr_or_err(
ffi::PyObject_Call(ptr, t.as_ptr(), kwargs.as_ptr()));
ffi::Py_DECREF(ptr);
self.py().release(t);
result
})