summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2017-08-18 19:04:39 +0200
committerStefan Behnel <stefan_ml@behnel.de>2017-08-18 19:04:39 +0200
commit7ec6b8a8f2fcbbb47152e43e3060736ffefc3eb5 (patch)
tree1dada78befb146aba714358bdacb62dd1417962c
parent1baac19e82fc0906f27832725f954243c50fc53e (diff)
parentebd45911af616797906c6d9264bc206af65a05b0 (diff)
downloadcython-7ec6b8a8f2fcbbb47152e43e3060736ffefc3eb5.tar.gz
Merge branch 'release'
-rw-r--r--CHANGES.rst5
-rw-r--r--Cython/Utility/Buffer.c5
2 files changed, 8 insertions, 2 deletions
diff --git a/CHANGES.rst b/CHANGES.rst
index b3e312e0e..089882f17 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -52,6 +52,11 @@ Bugs fixed
* ``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).
(Github issue #1801)
diff --git a/Cython/Utility/Buffer.c b/Cython/Utility/Buffer.c
index 68c603ea8..dfb8d1d92 100644
--- a/Cython/Utility/Buffer.c
+++ b/Cython/Utility/Buffer.c
@@ -128,14 +128,15 @@ static void __Pyx_ReleaseBuffer(Py_buffer *view) {
return;
}
+ if ((0));
{{for type_ptr, getbuffer, releasebuffer in types}}
{{if releasebuffer}}
- if (__Pyx_TypeCheck(obj, {{type_ptr}})) { {{releasebuffer}}(obj, view); return; }
+ else if (__Pyx_TypeCheck(obj, {{type_ptr}})) {{releasebuffer}}(obj, view);
{{endif}}
{{endfor}}
- Py_DECREF(obj);
view->obj = NULL;
+ Py_DECREF(obj);
}
#endif /* PY_MAJOR_VERSION < 3 */