mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-03-03 11:35:52 +03:00
fix truncated images loading
This commit is contained in:
parent
8c3f66a9ae
commit
b8b3cdc146
|
@ -33,7 +33,7 @@ import io
|
|||
import logging
|
||||
import os
|
||||
import sys
|
||||
# import traceback
|
||||
import struct
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -101,7 +101,8 @@ class ImageFile(Image.Image):
|
|||
except (IndexError, # end of data
|
||||
TypeError, # end of data (ord)
|
||||
KeyError, # unsupported mode
|
||||
EOFError) as v: # got header but not the first frame
|
||||
EOFError, # got header but not the first frame
|
||||
struct.error) as v:
|
||||
logger.exception("%s")
|
||||
raise SyntaxError(v)
|
||||
|
||||
|
@ -204,7 +205,7 @@ class ImageFile(Image.Image):
|
|||
while True:
|
||||
try:
|
||||
s = read(self.decodermaxblock)
|
||||
except IndexError as ie: # truncated png/gif
|
||||
except (IndexError, struct.error) as ie: # truncated png/gif
|
||||
if LOAD_TRUNCATED_IMAGES:
|
||||
break
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue
Block a user