Repository navigation
Commit ea5fbcc
authored
zlib: return output inflate still holds after the last input byte (#8909)
* zlib: return output inflate still holds after the last input byte
decompress_chunks returned before it called inflate when the input was
empty, and returned once the input was consumed even when the output
buffer was full. Raw deflate has no trailer, so inflate can consume the
last input byte and still hold output. Decompress.decompress(b"", n)
and Decompress.flush() then returned nothing, and zlib.decompress with a
small bufsize raised "incomplete or truncated stream".
Mirror CPython's zlibmodule.c: call inflate for empty input, and call it
again while it fills the output buffer. A stream with no pending output
answers Z_BUF_ERROR, so an empty input before any compressed data still
leaves eof false.
Assisted-by: Claude Code:claude-opus-5-5
Fixes #8907
* zlib: fold the full-buffer case into the loop's exit condition
Return when the stream ended, or when the input is used up and inflate
left part of the output buffer empty. A full buffer falls through to
the existing next iteration, as CPython's loop runs while avail_out is
zero, instead of a separate branch ahead of the exit check.
Assisted-by: Claude Code:claude-opus-5-5
* zlib: drop the comment that stood in for the removed early return
Assisted-by: Claude Code:claude-opus-5-51 parent 20295fd commit ea5fbcc
2 files changed
Lines changed: 97 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
406 | 406 | | |
407 | 407 | | |
408 | 408 | | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | 409 | | |
413 | 410 | | |
414 | 411 | | |
| |||
434 | 431 | | |
435 | 432 | | |
436 | 433 | | |
437 | | - | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
438 | 437 | | |
439 | 438 | | |
440 | 439 | | |
| |||
1078 | 1077 | | |
1079 | 1078 | | |
1080 | 1079 | | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
1081 | 1132 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
0 commit comments