File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
Expand file tree Collapse file tree 1 file changed +10
-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,16 @@ 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+ /* Retry only if both avail_in > 0 (more input to process) and avail_out > 0
1175+ * (output buffer has space). If avail_out == 0, the buffer is full and should
1176+ * be consumed by the caller first. If avail_in == 0, there's nothing more to process. */
1177+ if (z -> stream .avail_in > 0 && z -> stream .avail_out > 0 ) {
1178+ goto loop ;
1179+ }
11741180 }
11751181
1176- if (flush != Z_FINISH && err == Z_BUF_ERROR
1177- && z -> stream .avail_out > 0 ) {
1178- z -> flags |= ZSTREAM_FLAG_IN_STREAM ;
1182+ if (flush != Z_FINISH && err == Z_BUF_ERROR && z -> stream .avail_out > 0 ) {
1183+ z -> flags |= ZSTREAM_FLAG_IN_STREAM ;
11791184 }
11801185
11811186 zstream_reset_input (z );
You can’t perform that action at this time.
0 commit comments