* Fix thread lock in zlib.Decompress.flush() may go wrong
Getting `.unconsumed_tail` before acquiring the thread lock may mix up decompress state.
backport of https://github.com/python/cpython/pull/29587 to 3.9/3.8.
--- /dev/null
+Fix thread lock in ``zlib.Decompress.flush()`` method before ``PyObject_GetBuffer``.
return NULL;
}
- if (PyObject_GetBuffer(self->unconsumed_tail, &data, PyBUF_SIMPLE) == -1)
- return NULL;
-
ENTER_ZLIB(self);
+ if (PyObject_GetBuffer(self->unconsumed_tail, &data, PyBUF_SIMPLE) == -1) {
+ LEAVE_ZLIB(self);
+ return NULL;
+ }
+
self->zst.next_in = data.buf;
ibuflen = data.len;