mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
When reading past the end of a scan line, reduce bytes left
This commit is contained in:
parent
184b73ed64
commit
c846cc881e
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