Skip to content

Commit 57100c8

Browse files
[3.10] bpo-41735: Fix thread lock in zlib.Decompress.flush() may go wrong (GH-29587) (GH-29811)
* Fix thread lock in zlib.Decompress.flush() may go wrong Getting `.unconsumed_tail` before acquiring the thread lock may mix up decompress state. (cherry picked from commit 7edb627) Co-authored-by: Ma Lin <[email protected]> Automerge-Triggered-By: GH:gpshead
1 parent 3dcbe01 commit 57100c8

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix thread lock in ``zlib.Decompress.flush()`` method before ``PyObject_GetBuffer``.

Modules/zlibmodule.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,12 +1266,13 @@ zlib_Decompress_flush_impl(compobject *self, PyTypeObject *cls,
12661266
return NULL;
12671267
}
12681268

1269+
ENTER_ZLIB(self);
1270+
12691271
if (PyObject_GetBuffer(self->unconsumed_tail, &data, PyBUF_SIMPLE) == -1) {
1272+
LEAVE_ZLIB(self);
12701273
return NULL;
12711274
}
12721275

1273-
ENTER_ZLIB(self);
1274-
12751276
self->zst.next_in = data.buf;
12761277
ibuflen = data.len;
12771278

0 commit comments

Comments
 (0)