Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix thread locks in zlib module may go wrong in rare case. Patch by Ma Lin.
8 changes: 4 additions & 4 deletions Modules/zlibmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -785,15 +785,15 @@ 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;

/* limit amount of data allocated to max_length */
if (max_length && obuflen > max_length)
obuflen = max_length;

ENTER_ZLIB(self);

do {
arrange_input_buffer(&self->zst, &ibuflen);

Expand Down