[Python-3000-checkins] r65685 - in python/branches/py3k: Objects/abstract.c
martin.v.loewis
python-3000-checkins at python.org
Thu Aug 14 22:32:30 CEST 2008
Author: martin.v.loewis
Date: Thu Aug 14 22:32:30 2008
New Revision: 65685
Log:
Merged revisions 65677-65678,65683 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r65677 | martin.v.loewis | 2008-08-14 17:54:27 +0200 (Do, 14 Aug 2008) | 3 lines
Make obj an owned reference in Py_buffer; this checkin
was missing from the patch for #3139.
........
r65678 | martin.v.loewis | 2008-08-14 17:56:07 +0200 (Do, 14 Aug 2008) | 2 lines
Properly INCREF reference in Py_buffer.
........
r65683 | martin.v.loewis | 2008-08-14 22:12:06 +0200 (Do, 14 Aug 2008) | 2 lines
Fix memory leak: Always DECREF obj in PyBuffer_Release.
........
Modified:
python/branches/py3k/ (props changed)
python/branches/py3k/Objects/abstract.c
Modified: python/branches/py3k/Objects/abstract.c
==============================================================================
--- python/branches/py3k/Objects/abstract.c (original)
+++ python/branches/py3k/Objects/abstract.c Thu Aug 14 22:32:30 2008
@@ -670,6 +670,8 @@
}
view->obj = obj;
+ if (obj)
+ Py_INCREF(obj);
view->buf = buf;
view->len = len;
view->readonly = readonly;
@@ -693,11 +695,10 @@
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);
-
+ 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;
}
PyObject *
More information about the Python-3000-checkins
mailing list