mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 09:14:27 +03:00
Finish once enough data has been read
This commit is contained in:
parent
ae06f2e274
commit
9db527a473
|
@ -139,6 +139,13 @@ def test_rle8():
|
||||||
with Image.open("Tests/images/hopper_rle8_row_overflow.bmp") as im:
|
with Image.open("Tests/images/hopper_rle8_row_overflow.bmp") as im:
|
||||||
assert_image_similar_tofile(im.convert("RGB"), "Tests/images/hopper.bmp", 12)
|
assert_image_similar_tofile(im.convert("RGB"), "Tests/images/hopper.bmp", 12)
|
||||||
|
|
||||||
|
# Signal end of bitmap before the image is finished
|
||||||
|
with open("Tests/images/bmp/g/pal8rle.bmp", "rb") as fp:
|
||||||
|
data = fp.read(1063) + b"\x01"
|
||||||
|
with Image.open(io.BytesIO(data)) as im:
|
||||||
|
with pytest.raises(ValueError):
|
||||||
|
im.load()
|
||||||
|
|
||||||
|
|
||||||
def test_offset():
|
def test_offset():
|
||||||
# This image has been hexedited
|
# This image has been hexedited
|
||||||
|
|
|
@ -282,7 +282,7 @@ class BmpRleDecoder(ImageFile.PyDecoder):
|
||||||
def decode(self, buffer):
|
def decode(self, buffer):
|
||||||
data = bytearray()
|
data = bytearray()
|
||||||
x = 0
|
x = 0
|
||||||
while True:
|
while len(data) < self.state.xsize * self.state.ysize:
|
||||||
num_pixels = self.fd.read(1)[0]
|
num_pixels = self.fd.read(1)[0]
|
||||||
byte = self.fd.read(1)
|
byte = self.fd.read(1)
|
||||||
if num_pixels:
|
if num_pixels:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user