Skip to content

Commit

Permalink
load truncated PNG
Browse files Browse the repository at this point in the history
  • Loading branch information
homm committed Aug 23, 2024
1 parent 73f4359 commit cc632ca
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/PIL/PngImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -992,16 +992,21 @@ def load_end(self):
length -= 4
try:
ImageFile._safe_read(self.fp, length)
except OSError as e:
except OSError:
if ImageFile.LOAD_TRUNCATED_IMAGES:
break
else:
raise e
raise
except AttributeError:
logger.debug("%r %s %s (unknown)", cid, pos, length)
s = ImageFile._safe_read(self.fp, length)
if cid[1:2].islower():
self.private_chunks.append((cid, s, True))
try:
s = ImageFile._safe_read(self.fp, length)
except OSError:
if ImageFile.LOAD_TRUNCATED_IMAGES:
break
raise
else:
if cid[1:2].islower():
self.private_chunks.append((cid, s, True))
self._text = self.png.im_text
if not self.is_animated:
self.png.close()
Expand Down

0 comments on commit cc632ca

Please sign in to comment.