diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index 0b51e81..941b7be 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -1053,6 +1053,8 @@ zstream_run_func(struct zstream_run_args *args) while (!args->interrupt) { n = z->stream.avail_out; + rb_str_locktmp(z->buf); + #ifndef RB_NOGVL_UBF_ASYNC_SAFE err = (int)(VALUE)rb_thread_call_without_gvl(zstream_run_once, (void *)args, zstream_unblock_func, (void *)args); #else @@ -1060,6 +1062,7 @@ zstream_run_func(struct zstream_run_args *args) #endif rb_str_set_len(z->buf, ZSTREAM_BUF_FILLED(z) + (n - z->stream.avail_out)); + rb_str_unlocktmp(z->buf); if (err == Z_STREAM_END) { z->flags &= ~ZSTREAM_FLAG_IN_STREAM;