mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 01:04:29 +03:00
Merge pull request #3965 from radarhere/truncated
Raise the same error if a truncated image is loaded a second time
This commit is contained in:
commit
8e3c4e3658
|
@ -369,6 +369,10 @@ class TestFileJpeg(PillowTestCase):
|
||||||
with self.assertRaises(IOError):
|
with self.assertRaises(IOError):
|
||||||
im.load()
|
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):
|
def _n_qtables_helper(self, n, test_file):
|
||||||
im = Image.open(test_file)
|
im = Image.open(test_file)
|
||||||
f = self.tempfile("temp.jpg")
|
f = self.tempfile("temp.jpg")
|
||||||
|
|
|
@ -111,6 +111,10 @@ class TestImageFile(PillowTestCase):
|
||||||
with self.assertRaises(IOError):
|
with self.assertRaises(IOError):
|
||||||
im.load()
|
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):
|
def test_truncated_without_errors(self):
|
||||||
if "zip_encoder" not in codecs:
|
if "zip_encoder" not in codecs:
|
||||||
self.skipTest("PNG (zlib) encoder not available")
|
self.skipTest("PNG (zlib) encoder not available")
|
||||||
|
|
|
@ -244,7 +244,6 @@ class ImageFile(Image.Image):
|
||||||
if LOAD_TRUNCATED_IMAGES:
|
if LOAD_TRUNCATED_IMAGES:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
self.tile = []
|
|
||||||
raise IOError(
|
raise IOError(
|
||||||
"image file is truncated "
|
"image file is truncated "
|
||||||
"(%d bytes not processed)" % len(b)
|
"(%d bytes not processed)" % len(b)
|
||||||
|
|
|
@ -612,7 +612,7 @@ class PngImageFile(ImageFile.ImageFile):
|
||||||
rawmode, data = self.png.im_palette
|
rawmode, data = self.png.im_palette
|
||||||
self.palette = ImagePalette.raw(rawmode, data)
|
self.palette = ImagePalette.raw(rawmode, data)
|
||||||
|
|
||||||
self.__idat = length # used by load_read()
|
self.__prepare_idat = length # used by load_prepare()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def text(self):
|
def text(self):
|
||||||
|
@ -645,6 +645,7 @@ class PngImageFile(ImageFile.ImageFile):
|
||||||
if self.info.get("interlace"):
|
if self.info.get("interlace"):
|
||||||
self.decoderconfig = self.decoderconfig + (1,)
|
self.decoderconfig = self.decoderconfig + (1,)
|
||||||
|
|
||||||
|
self.__idat = self.__prepare_idat # used by load_read()
|
||||||
ImageFile.ImageFile.load_prepare(self)
|
ImageFile.ImageFile.load_prepare(self)
|
||||||
|
|
||||||
def load_read(self, read_bytes):
|
def load_read(self, read_bytes):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user