File tree Expand file tree Collapse file tree 2 files changed +4
-2
lines changed Expand file tree Collapse file tree 2 files changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -199,7 +199,7 @@ cpdef decompress(data,
199
199
200
200
# Implementation imitated from CPython's zlibmodule.c
201
201
try :
202
- while ibuflen != 0 or stream.block_state != ISAL_BLOCK_FINISH:
202
+ while ibuflen != 0 and stream.block_state != ISAL_BLOCK_FINISH:
203
203
ibuflen = Py_ssize_t_min(remains, max_input_buffer)
204
204
ibuf = data[position: position + ibuflen]
205
205
position += ibuflen
@@ -225,6 +225,8 @@ cpdef decompress(data,
225
225
out.append(obuf[:obuflen - stream.avail_out])
226
226
if stream.avail_in == 0 :
227
227
break
228
+ if stream.block_state != ISAL_BLOCK_FINISH:
229
+ raise IsalError(" incomplete or truncated stream" )
228
230
return b" " .join(out)
229
231
finally :
230
232
PyMem_Free(obuf)
Original file line number Diff line number Diff line change @@ -207,7 +207,7 @@ def test_incomplete_stream(self):
207
207
# A useful error message is given
208
208
x = isal_zlib .compress (HAMLET_SCENE )
209
209
self .assertRaisesRegex (isal_zlib .error ,
210
- "Error -5 while decompressing data: incomplete or truncated stream" ,
210
+ "incomplete or truncated stream" ,
211
211
isal_zlib .decompress , x [:- 1 ])
212
212
213
213
# Memory use of the following functions takes into account overallocation
You can’t perform that action at this time.
0 commit comments