File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed
Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -1094,8 +1094,9 @@ zstream_run_func(struct zstream_run_args *args)
10941094 break ;
10951095 }
10961096
1097- if (err != Z_OK && err != Z_BUF_ERROR )
1097+ if (err != Z_OK && err != Z_BUF_ERROR ) {
10981098 break ;
1099+ }
10991100
11001101 if (z -> stream .avail_out > 0 ) {
11011102 z -> flags |= ZSTREAM_FLAG_IN_STREAM ;
@@ -1170,12 +1171,17 @@ zstream_run_try(VALUE value_arg)
11701171 /* retry if no exception is thrown */
11711172 if (err == Z_OK && args -> interrupt ) {
11721173 args -> interrupt = 0 ;
1173- goto loop ;
1174+
1175+ /* Retry only if both avail_in > 0 (more input to process) and avail_out > 0
1176+ * (output buffer has space). If avail_out == 0, the buffer is full and should
1177+ * be consumed by the caller first. If avail_in == 0, there's nothing more to process. */
1178+ if (z -> stream .avail_in > 0 && z -> stream .avail_out > 0 ) {
1179+ goto loop ;
1180+ }
11741181 }
11751182
1176- if (flush != Z_FINISH && err == Z_BUF_ERROR
1177- && z -> stream .avail_out > 0 ) {
1178- z -> flags |= ZSTREAM_FLAG_IN_STREAM ;
1183+ if (flush != Z_FINISH && err == Z_BUF_ERROR && z -> stream .avail_out > 0 ) {
1184+ z -> flags |= ZSTREAM_FLAG_IN_STREAM ;
11791185 }
11801186
11811187 zstream_reset_input (z );
You can’t perform that action at this time.
0 commit comments