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:
164
164
with pytest .raises (OSError ):
165
165
p .close ()
166
166
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
+
167
172
def test_no_format (self ) -> None :
168
173
buf = BytesIO (b"\x00 " * 255 )
169
174
Original file line number Diff line number Diff line change @@ -313,6 +313,9 @@ def load(self) -> Image.core.PixelAccess | None:
313
313
and args [0 ] == self .mode
314
314
and args [0 ] in Image ._MAPMODES
315
315
):
316
+ if offset < 0 :
317
+ msg = "Tile offset cannot be negative"
318
+ raise ValueError (msg )
316
319
try :
317
320
# use mmap, if possible
318
321
import mmap
You can’t perform that action at this time.
0 commit comments