File tree Expand file tree Collapse file tree 2 files changed +8
-0
lines changed
Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -164,6 +164,11 @@ def test_negative_stride(self) -> None:
164164 with pytest .raises (OSError ):
165165 p .close ()
166166
167+ def test_negative_offset (self ) -> None :
168+ with Image .open ("Tests/images/raw_negative_stride.bin" ) as im :
169+ with pytest .raises (ValueError , match = "Tile offset cannot be negative" ):
170+ im .load ()
171+
167172 def test_no_format (self ) -> None :
168173 buf = BytesIO (b"\x00 " * 255 )
169174
Original file line number Diff line number Diff line change @@ -313,6 +313,9 @@ def load(self) -> Image.core.PixelAccess | None:
313313 and args [0 ] == self .mode
314314 and args [0 ] in Image ._MAPMODES
315315 ):
316+ if offset < 0 :
317+ msg = "Tile offset cannot be negative"
318+ raise ValueError (msg )
316319 try :
317320 # use mmap, if possible
318321 import mmap
You can’t perform that action at this time.
0 commit comments