summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorMa Lin <animalize@users.noreply.github.com>2021-11-27 00:18:17 (GMT)
committerGitHub <noreply@github.com>2021-11-27 00:18:17 (GMT)
commit7edb6270a78c695e4c2ae2432797dc18105374fc (patch)
treedfd17acdc4e4dd694458e99e14a63db718165cee /Modules
parent4841e694ee1686f8c933ddfcb8c854915867ce17 (diff)
downloadcpython-7edb6270a78c695e4c2ae2432797dc18105374fc.zip
cpython-7edb6270a78c695e4c2ae2432797dc18105374fc.tar.gz
cpython-7edb6270a78c695e4c2ae2432797dc18105374fc.tar.bz2
bpo-41735: Fix thread lock in zlib.Decompress.flush() may go wrong (GH-29587)
* Fix thread lock in zlib.Decompress.flush() may go wrong Getting `.unconsumed_tail` before acquiring the thread lock may mix up decompress state.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/zlibmodule.c5
1 files changed, 3 insertions, 2 deletions
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;