diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2008-08-14 20:12:06 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2008-08-14 20:12:06 (GMT) |
commit | 64034f994c4f176c7a6c9747d8caf86d8df243cd (patch) | |
tree | b6907d9796e392478ccb6794a292bc28b348af2c /Objects | |
parent | 6d2014ee590aafd90143167bd465b6fb1ab7cf6f (diff) | |
download | cpython-64034f994c4f176c7a6c9747d8caf86d8df243cd.zip cpython-64034f994c4f176c7a6c9747d8caf86d8df243cd.tar.gz cpython-64034f994c4f176c7a6c9747d8caf86d8df243cd.tar.bz2 |
Fix memory leak: Always DECREF obj in PyBuffer_Release.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/abstract.c | 8 |
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; } |