mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-04 13:40:54 +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)
|
||||
|
||||
|
||||
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:
|
||||
class TestHandler(ImageFile.StubHandler):
|
||||
methodCalled = False
|
||||
|
|
|
@ -92,6 +92,9 @@ class WmfStubImageFile(ImageFile.StubImageFile):
|
|||
|
||||
# get units per inch
|
||||
self._inch = word(s, 14)
|
||||
if self._inch == 0:
|
||||
msg = "Invalid inch"
|
||||
raise ValueError(msg)
|
||||
|
||||
# get bounding box
|
||||
x0 = short(s, 6)
|
||||
|
|
Loading…
Reference in New Issue
Block a user