From 7436501a2a13ca201562f6c3d48824ba31f7602c Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Wed, 2 Jan 2019 10:46:51 -0500 Subject: [PATCH] FIX: fix PngImageFile.load_end Ensure that the flow-control EOFError exceptions are properly handled. closes #3527 --- src/PIL/PngImagePlugin.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/PIL/PngImagePlugin.py b/src/PIL/PngImagePlugin.py index 04161a56c..4163c4297 100644 --- a/src/PIL/PngImagePlugin.py +++ b/src/PIL/PngImagePlugin.py @@ -677,6 +677,11 @@ class PngImageFile(ImageFile.ImageFile): self.png.call(cid, pos, length) except UnicodeDecodeError: break + except EOFError: + # call dispatches out to chunk_* methods which + # mutate the internal state and then raise EOFError + # for a chunk that must be last. + break self._text = self.png.im_text self.png.close() self.png = None