diff --git a/src/PIL/AniImagePlugin.py b/src/PIL/AniImagePlugin.py index 9f1c518c4..cab8287d6 100644 --- a/src/PIL/AniImagePlugin.py +++ b/src/PIL/AniImagePlugin.py @@ -278,7 +278,6 @@ def _save(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None: _write_multiple_frames(im, fp) else: _write_single_frame(im, fp) - pass riff_end = fp.tell() fp.seek(riff_offset - 4) @@ -289,28 +288,29 @@ def _save(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None: class AniFile: - def __init__(self, buf: BytesIO) -> None: + def __init__(self, fp: BytesIO) -> None: + if not _accept(fp.read(4)): + SyntaxError("Not an ANI file") + self.image_data = [] - self.buf = buf + self.buf = fp self.rate = None self.seq = None self.anih = None - riff, size, fformat = struct.unpack("<4sI4s", buf.read(12)) - if riff != b"RIFF": - SyntaxError("Not an ANI file") + size, fformat = struct.unpack("