Skip to content

Commit c846cc8

Browse files
radarherehugovk
authored andcommitted
When reading past the end of a scan line, reduce bytes left
1 parent 184b73e commit c846cc8

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed
4.77 KB
Binary file not shown.

Tests/test_file_tga.py

+4
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ def test_cross_scan_line():
101101
with Image.open("Tests/images/cross_scan_line.tga") as im:
102102
assert_image_equal_tofile(im, "Tests/images/cross_scan_line.png")
103103

104+
with Image.open("Tests/images/cross_scan_line_truncated.tga") as im:
105+
with pytest.raises(OSError):
106+
im.load()
107+
104108

105109
def test_save(tmp_path):
106110
test_file = "Tests/images/tga_id_field.tga"

src/libImaging/TgaRleDecode.c

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ ImagingTgaRleDecode(Imaging im, ImagingCodecState state, UINT8 *buf, Py_ssize_t
120120
}
121121
memcpy(state->buffer + state->x, ptr, n);
122122
ptr += n;
123+
bytes -= n;
123124
extra_bytes -= n;
124125
}
125126
}

0 commit comments

Comments
 (0)