mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
Raise the same error if a truncated image is loaded a second time
This commit is contained in:
parent
1c57a41ece
commit
023dcf27c2
|
@ -372,6 +372,10 @@ class TestFileJpeg(PillowTestCase):
|
|||
with self.assertRaises(IOError):
|
||||
im.load()
|
||||
|
||||
# Test that the error is raised if loaded a second time
|
||||
with self.assertRaises(IOError):
|
||||
im.load()
|
||||
|
||||
def _n_qtables_helper(self, n, test_file):
|
||||
im = Image.open(test_file)
|
||||
f = self.tempfile("temp.jpg")
|
||||
|
|
|
@ -113,6 +113,10 @@ class TestImageFile(PillowTestCase):
|
|||
with self.assertRaises(IOError):
|
||||
im.load()
|
||||
|
||||
# Test that the error is raised if loaded a second time
|
||||
with self.assertRaises(IOError):
|
||||
im.load()
|
||||
|
||||
def test_truncated_without_errors(self):
|
||||
if "zip_encoder" not in codecs:
|
||||
self.skipTest("PNG (zlib) encoder not available")
|
||||
|
|
|
@ -243,7 +243,6 @@ class ImageFile(Image.Image):
|
|||
if LOAD_TRUNCATED_IMAGES:
|
||||
break
|
||||
else:
|
||||
self.tile = []
|
||||
raise IOError(
|
||||
"image file is truncated "
|
||||
"(%d bytes not processed)" % len(b)
|
||||
|
|
|
@ -612,7 +612,7 @@ class PngImageFile(ImageFile.ImageFile):
|
|||
rawmode, data = self.png.im_palette
|
||||
self.palette = ImagePalette.raw(rawmode, data)
|
||||
|
||||
self.__idat = length # used by load_read()
|
||||
self.__prepare_idat = length # used by load_prepare()
|
||||
|
||||
@property
|
||||
def text(self):
|
||||
|
@ -645,6 +645,7 @@ class PngImageFile(ImageFile.ImageFile):
|
|||
if self.info.get("interlace"):
|
||||
self.decoderconfig = self.decoderconfig + (1,)
|
||||
|
||||
self.__idat = self.__prepare_idat # used by load_read()
|
||||
ImageFile.ImageFile.load_prepare(self)
|
||||
|
||||
def load_read(self, read_bytes):
|
||||
|
|
Loading…
Reference in New Issue
Block a user