When reading past the end of a scan line, reduce bytes left

This commit is contained in:
Andrew Murray 2022-05-15 13:51:31 +10:00 committed by Hugo van Kemenade
parent 184b73ed64
commit c846cc881e
3 changed files with 5 additions and 0 deletions

Binary file not shown.

View File

@ -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"

View File

@ -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;
}
}