Fix memory leak: Always DECREF obj in PyBuffer_Release.

This commit is contained in:
Martin v. Löwis 2008-08-14 20:12:06 +00:00
parent 6d2014ee59
commit 64034f994c
1 changed files with 3 additions and 5 deletions

View File

@ -708,11 +708,9 @@ void
PyBuffer_Release(Py_buffer *view)
{
PyObject *obj = view->obj;
if (!obj || !Py_TYPE(obj)->tp_as_buffer || !Py_TYPE(obj)->tp_as_buffer->bf_releasebuffer)
/* Unmanaged buffer */
return;
Py_TYPE(obj)->tp_as_buffer->bf_releasebuffer(obj, view);
Py_DECREF(obj);
if (obj && Py_TYPE(obj)->tp_as_buffer && Py_TYPE(obj)->tp_as_buffer->bf_releasebuffer)
Py_TYPE(obj)->tp_as_buffer->bf_releasebuffer(obj, view);
Py_XDECREF(obj);
view->obj = NULL;
}