summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Misc/NEWS.d/next/Library/2021-11-16-18-13-49.bpo-41735.D72UY1.rst1
-rw-r--r--Modules/zlibmodule.c5
2 files changed, 4 insertions, 2 deletions
diff --git a/Misc/NEWS.d/next/Library/2021-11-16-18-13-49.bpo-41735.D72UY1.rst b/Misc/NEWS.d/next/Library/2021-11-16-18-13-49.bpo-41735.D72UY1.rst
new file mode 100644
index 0000000..101da0e
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2021-11-16-18-13-49.bpo-41735.D72UY1.rst
@@ -0,0 +1 @@
+Fix thread lock in ``zlib.Decompress.flush()`` method before ``PyObject_GetBuffer``.
diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c
index 67bde70..f964656 100644
--- a/Modules/zlibmodule.c
+++ b/Modules/zlibmodule.c
@@ -1269,12 +1269,13 @@ zlib_Decompress_flush_impl(compobject *self, PyTypeObject *cls,
return NULL;
}
+ ENTER_ZLIB(self);
+
if (PyObject_GetBuffer(self->unconsumed_tail, &data, PyBUF_SIMPLE) == -1) {
+ LEAVE_ZLIB(self);
return NULL;
}
- ENTER_ZLIB(self);
-
self->zst.next_in = data.buf;
ibuflen = data.len;