From fbaaf3c19b0b27206205c7ce95e95db1190f227e Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 26 Feb 2022 16:30:44 +1100 Subject: [PATCH] Do not read data until necessary --- src/PIL/GbrImagePlugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PIL/GbrImagePlugin.py b/src/PIL/GbrImagePlugin.py index 3d8fc47b2..4caeda8ef 100644 --- a/src/PIL/GbrImagePlugin.py +++ b/src/PIL/GbrImagePlugin.py @@ -43,9 +43,9 @@ class GbrImageFile(ImageFile.ImageFile): def _open(self): header_size = i32(self.fp.read(4)) - version = i32(self.fp.read(4)) if header_size < 20: raise SyntaxError("not a GIMP brush") + version = i32(self.fp.read(4)) if version not in (1, 2): raise SyntaxError(f"Unsupported GIMP brush version: {version}")