Skip to content

Commit

Permalink
If next byte ends the GIF, stay on the current frame
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Feb 21, 2022
1 parent 73cf28c commit 590c616
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/PIL/GifImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,6 @@ def _seek(self, frame):

if frame != self.__frame + 1:
raise ValueError(f"cannot seek to frame {frame}")
self.__frame = frame

self.tile = []

self.fp = self.__fp
if self.__offset:
Expand All @@ -166,6 +163,14 @@ def _seek(self, frame):
pass
self.__offset = 0

s = self.fp.read(1)
if not s or s == b";":
raise EOFError

self.__frame = frame

self.tile = []

if self.__frame == 1:
self.pyaccess = None
if "transparency" in self.info:
Expand All @@ -187,7 +192,8 @@ def _seek(self, frame):
interlace = None
while True:

s = self.fp.read(1)
if not s:
s = self.fp.read(1)
if not s or s == b";":
break

Expand Down Expand Up @@ -225,6 +231,7 @@ def _seek(self, frame):
else:
info["comment"] = block
block = self.data()
s = None
continue
elif s[0] == 255:
#
Expand Down Expand Up @@ -266,6 +273,7 @@ def _seek(self, frame):
else:
pass
# raise OSError, "illegal GIF tag `%x`" % s[0]
s = None

frame_palette = palette or self.global_palette

Expand Down

0 comments on commit 590c616

Please sign in to comment.