mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
When reading past the end of a scan line, reduce bytes left
This commit is contained in:
parent
638ba163f4
commit
f0353c5996
BIN
Tests/images/cross_scan_line_truncated.tga
Normal file
BIN
Tests/images/cross_scan_line_truncated.tga
Normal file
Binary file not shown.
|
@ -101,6 +101,10 @@ def test_cross_scan_line():
|
|||
with Image.open("Tests/images/cross_scan_line.tga") as im:
|
||||
assert_image_equal_tofile(im, "Tests/images/cross_scan_line.png")
|
||||
|
||||
with Image.open("Tests/images/cross_scan_line_truncated.tga") as im:
|
||||
with pytest.raises(OSError):
|
||||
im.load()
|
||||
|
||||
|
||||
def test_save(tmp_path):
|
||||
test_file = "Tests/images/tga_id_field.tga"
|
||||
|
|
|
@ -120,6 +120,7 @@ ImagingTgaRleDecode(Imaging im, ImagingCodecState state, UINT8 *buf, Py_ssize_t
|
|||
}
|
||||
memcpy(state->buffer + state->x, ptr, n);
|
||||
ptr += n;
|
||||
bytes -= n;
|
||||
extra_bytes -= n;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user