Commit ebd45911 authored by Stefan Behnel's avatar Stefan Behnel

Fix reference leak in the Py2.x __Pyx_ReleaseBuffer() implementation for types...

Fix reference leak in the Py2.x __Pyx_ReleaseBuffer() implementation for types with an overridden __releasebuffer__ method.

Closes #1638.
parent 8c559493
...@@ -14,6 +14,11 @@ Bugs fixed ...@@ -14,6 +14,11 @@ Bugs fixed
* ``cython.view.array`` was missing ``.__len__()``. * ``cython.view.array`` was missing ``.__len__()``.
* Extension types with a ``.pxd`` override for their ``__releasebuffer__`` slot
(e.g. as provided by Cython for the Python ``array.array`` type) could leak
a reference to the buffer owner on release, thus not freeing the memory.
(Github issue #1638)
* Invalid C code in generators (declaration after code). * Invalid C code in generators (declaration after code).
(Github issue #1801) (Github issue #1801)
......
...@@ -128,14 +128,15 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) { ...@@ -128,14 +128,15 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) {
return; return;
} }
if ((0));
{{for type_ptr, getbuffer, releasebuffer in types}} {{for type_ptr, getbuffer, releasebuffer in types}}
{{if releasebuffer}} {{if releasebuffer}}
if (PyObject_TypeCheck(obj, {{type_ptr}})) { {{releasebuffer}}(obj, view); return; } else if (PyObject_TypeCheck(obj, {{type_ptr}})) {{releasebuffer}}(obj, view);
{{endif}} {{endif}}
{{endfor}} {{endfor}}
Py_DECREF(obj);
view->obj = NULL; view->obj = NULL;
Py_DECREF(obj);
} }
#endif /* PY_MAJOR_VERSION < 3 */ #endif /* PY_MAJOR_VERSION < 3 */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment