From 7ecf9f61d3f59952c734be3d37c3fc6036a0a4c4 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 8 Sep 2018 20:21:26 +1000 Subject: [PATCH] Close existing fp before setting new fp --- src/PIL/WebPImagePlugin.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/PIL/WebPImagePlugin.py b/src/PIL/WebPImagePlugin.py index 39a8f2e35dd..8c26da180bc 100644 --- a/src/PIL/WebPImagePlugin.py +++ b/src/PIL/WebPImagePlugin.py @@ -153,6 +153,8 @@ def load(self): self.__loaded = self.__logical_frame # Set tile + if self.fp: + self.fp.close() self.fp = BytesIO(data) self.tile = [("raw", (0, 0) + self.size, 0, self.mode)]