From 22d3e6a60162f6a1151ed303ba7199f848808799 Mon Sep 17 00:00:00 2001 From: Jonathan Michalon Date: Tue, 23 Feb 2016 14:08:39 +0100 Subject: [PATCH] SpiderImagePlugin: raise an error when seeking in a non-stack file Using ImageSequence.Iterator on a non-stack SPIDER image leads to infinite loop. EOFError (which stops the iteration) is never raised because when the image isn't a stack, seek() returns gently without error. --- PIL/SpiderImagePlugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PIL/SpiderImagePlugin.py b/PIL/SpiderImagePlugin.py index d5457893c..a59329497 100644 --- a/PIL/SpiderImagePlugin.py +++ b/PIL/SpiderImagePlugin.py @@ -173,7 +173,7 @@ class SpiderImageFile(ImageFile.ImageFile): def seek(self, frame): if self.istack == 0: - return + raise EOFError("attempt to seek in a non-stack file") if frame >= self._nimages: raise EOFError("attempt to seek past end of file") self.stkoffset = self.hdrlen + frame * (self.hdrlen + self.imgbytes)