[Python-checkins] r65683 - python/trunk/Objects/abstract.c

martin.v.loewis python-checkins at python.org
Thu Aug 14 22:12:06 CEST 2008


Author: martin.v.loewis
Date: Thu Aug 14 22:12:06 2008
New Revision: 65683

Log:
Fix memory leak: Always DECREF obj in PyBuffer_Release.


Modified:
   python/trunk/Objects/abstract.c

Modified: python/trunk/Objects/abstract.c
==============================================================================
--- python/trunk/Objects/abstract.c	(original)
+++ python/trunk/Objects/abstract.c	Thu Aug 14 22:12:06 2008
@@ -708,11 +708,9 @@
 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;
 }
 


More information about the Python-checkins mailing list