mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
Fix thread locks in zlib module may go wrong in rare case (#22130)
Setting `next_in` before acquiring the thread lock may mix up compress/decompress state in other threads.
This commit is contained in:
parent
d0698c676c
commit
ba7338a460
2 changed files with 5 additions and 4 deletions
|
@ -0,0 +1 @@
|
|||
Fix thread locks in zlib module may go wrong in rare case. Patch by Ma Lin.
|
|
@ -667,11 +667,11 @@ zlib_Compress_compress_impl(compobject *self, Py_buffer *data)
|
|||
Py_ssize_t ibuflen, obuflen = DEF_BUF_SIZE;
|
||||
int err;
|
||||
|
||||
ENTER_ZLIB(self);
|
||||
|
||||
self->zst.next_in = data->buf;
|
||||
ibuflen = data->len;
|
||||
|
||||
ENTER_ZLIB(self);
|
||||
|
||||
do {
|
||||
arrange_input_buffer(&self->zst, &ibuflen);
|
||||
|
||||
|
@ -785,6 +785,8 @@ zlib_Decompress_decompress_impl(compobject *self, Py_buffer *data,
|
|||
else
|
||||
hard_limit = max_length;
|
||||
|
||||
ENTER_ZLIB(self);
|
||||
|
||||
self->zst.next_in = data->buf;
|
||||
ibuflen = data->len;
|
||||
|
||||
|
@ -792,8 +794,6 @@ zlib_Decompress_decompress_impl(compobject *self, Py_buffer *data,
|
|||
if (max_length && obuflen > max_length)
|
||||
obuflen = max_length;
|
||||
|
||||
ENTER_ZLIB(self);
|
||||
|
||||
do {
|
||||
arrange_input_buffer(&self->zst, &ibuflen);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue