summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2008-08-14 20:32:30 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2008-08-14 20:32:30 (GMT)
commit74bbea7ed7a75a180d02846e93b53e24ef6ca651 (patch)
tree47fc7a2f565274bebdaa4450b86c6752799b5fc6
parent23e3856b1e275aaff210723d4bbafbdd61cd8e75 (diff)
downloadcpython-74bbea7ed7a75a180d02846e93b53e24ef6ca651.zip
cpython-74bbea7ed7a75a180d02846e93b53e24ef6ca651.tar.gz
cpython-74bbea7ed7a75a180d02846e93b53e24ef6ca651.tar.bz2
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. ........
-rw-r--r--Objects/abstract.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c
index 6b73aca..8f7083d 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -670,6 +670,8 @@ PyBuffer_FillInfo(Py_buffer *view, PyObject *obj, void *buf, Py_ssize_t len,
}
view->obj = obj;
+ if (obj)
+ Py_INCREF(obj);
view->buf = buf;
view->len = len;
view->readonly = readonly;
@@ -693,11 +695,10 @@ 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);
-
+ 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 *