diff options
| author | Ma Lin <animalize@users.noreply.github.com> | 2021-11-27 08:18:17 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-26 16:18:17 -0800 |
| commit | 7edb6270a78c695e4c2ae2432797dc18105374fc (patch) | |
| tree | dfd17acdc4e4dd694458e99e14a63db718165cee /Modules/zlibmodule.c | |
| parent | 4841e694ee1686f8c933ddfcb8c854915867ce17 (diff) | |
| download | cpython-git-7edb6270a78c695e4c2ae2432797dc18105374fc.tar.gz | |
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/zlibmodule.c')
| -rw-r--r-- | Modules/zlibmodule.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c index 67bde701fa..f9646568d7 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; |
