Skip to content

Commit

Permalink
Limit raw tile size to avoid extending outside image
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Jun 15, 2022
1 parent e80ddfd commit f51fc71
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
Binary file added Tests/images/input_bw_one_band.fpx
Binary file not shown.
Binary file added Tests/images/input_bw_one_band.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions Tests/test_file_fpx.py
Expand Up @@ -2,11 +2,22 @@

from PIL import Image

from .helper import assert_image_equal_tofile

FpxImagePlugin = pytest.importorskip(
"PIL.FpxImagePlugin", reason="olefile not installed"
)


def test_sanity():
with Image.open("Tests/images/input_bw_one_band.fpx") as im:
assert im.mode == "L"
assert im.size == (70, 46)
assert im.format == "FPX"

assert_image_equal_tofile(im, "Tests/images/input_bw_one_band.png")


def test_invalid_file():
# Test an invalid OLE file
invalid_file = "Tests/images/flower.jpg"
Expand Down
2 changes: 1 addition & 1 deletion src/PIL/FpxImagePlugin.py
Expand Up @@ -160,7 +160,7 @@ def _open_subimage(self, index=1, subimage=0):
self.tile.append(
(
"raw",
(x, y, x + xtile, y + ytile),
(x, y, min(xsize, x + xtile), min(ysize, y + ytile)),
i32(s, i) + 28,
(self.rawmode,),
)
Expand Down

0 comments on commit f51fc71

Please sign in to comment.