diff --git a/Tests/test_file_wmf.py b/Tests/test_file_wmf.py index c837583f15a..45aa80f56af 100644 --- a/Tests/test_file_wmf.py +++ b/Tests/test_file_wmf.py @@ -118,9 +118,13 @@ def test_load_set_dpi() -> None: with Image.open("Tests/images/drawing.emf") as im: assert im.size == (1625, 1625) + assert isinstance(im, WmfImagePlugin.WmfStubImageFile) + with pytest.raises(Image.DecompressionBombError): + im.load(20000) - if not hasattr(Image.core, "drawwmf"): - return + if not hasattr(Image.core, "drawwmf"): + return + with Image.open("Tests/images/drawing.emf") as im: assert isinstance(im, WmfImagePlugin.WmfStubImageFile) im.load(im.info["dpi"]) assert im.size == (1625, 1625) diff --git a/src/PIL/WmfImagePlugin.py b/src/PIL/WmfImagePlugin.py index 1815933b4c0..15dccae93fa 100644 --- a/src/PIL/WmfImagePlugin.py +++ b/src/PIL/WmfImagePlugin.py @@ -128,6 +128,7 @@ def load( int((x1 - x0) * dpi[0] / self._inch[0]), int((y1 - y0) * dpi[1] / self._inch[1]), ) + Image._decompression_bomb_check(self.size) return super().load()