summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2008-08-14 20:12:06 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2008-08-14 20:12:06 (GMT)
commit64034f994c4f176c7a6c9747d8caf86d8df243cd (patch)
treeb6907d9796e392478ccb6794a292bc28b348af2c
parent6d2014ee590aafd90143167bd465b6fb1ab7cf6f (diff)
downloadcpython-64034f994c4f176c7a6c9747d8caf86d8df243cd.zip
cpython-64034f994c4f176c7a6c9747d8caf86d8df243cd.tar.gz
cpython-64034f994c4f176c7a6c9747d8caf86d8df243cd.tar.bz2
Fix memory leak: Always DECREF obj in PyBuffer_Release.
-rw-r--r--Objects/abstract.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c
index aca60bd..68e1549 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -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;
}