mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-10 00:20:57 +03:00
Raise ValueError when WMF inch is zero (#8600)
Co-authored-by: Andrew Murray <radarhere@users.noreply.github.com>
This commit is contained in:
parent
de8335ba8f
commit
cbc55c4621
|
@ -35,6 +35,13 @@ def test_load() -> None:
|
||||||
assert im.load()[0, 0] == (255, 255, 255)
|
assert im.load()[0, 0] == (255, 255, 255)
|
||||||
|
|
||||||
|
|
||||||
|
def test_load_zero_inch() -> None:
|
||||||
|
b = BytesIO(b"\xd7\xcd\xc6\x9a\x00\x00" + b"\x00" * 10)
|
||||||
|
with pytest.raises(ValueError):
|
||||||
|
with Image.open(b):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def test_register_handler(tmp_path: Path) -> None:
|
def test_register_handler(tmp_path: Path) -> None:
|
||||||
class TestHandler(ImageFile.StubHandler):
|
class TestHandler(ImageFile.StubHandler):
|
||||||
methodCalled = False
|
methodCalled = False
|
||||||
|
|
|
@ -92,6 +92,9 @@ class WmfStubImageFile(ImageFile.StubImageFile):
|
||||||
|
|
||||||
# get units per inch
|
# get units per inch
|
||||||
self._inch = word(s, 14)
|
self._inch = word(s, 14)
|
||||||
|
if self._inch == 0:
|
||||||
|
msg = "Invalid inch"
|
||||||
|
raise ValueError(msg)
|
||||||
|
|
||||||
# get bounding box
|
# get bounding box
|
||||||
x0 = short(s, 6)
|
x0 = short(s, 6)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user