diff --git a/Tests/check_fli_overflow.py b/Tests/check_fli_overflow.py new file mode 100644 index 000000000..d89a82761 --- /dev/null +++ b/Tests/check_fli_overflow.py @@ -0,0 +1,16 @@ +from helper import unittest, PillowTestCase +from PIL import Image + +TEST_FILE = "Tests/images/fli_overflow.fli" + + +class TestFliOverflow(PillowTestCase): + def test_fli_overflow(self): + + # this should not crash with a malloc error or access violation + im = Image.open(TEST_FILE) + im.load() + + +if __name__ == '__main__': + unittest.main() diff --git a/Tests/images/fli_overflow.fli b/Tests/images/fli_overflow.fli new file mode 100644 index 000000000..bea12160e Binary files /dev/null and b/Tests/images/fli_overflow.fli differ diff --git a/libImaging/FliDecode.c b/libImaging/FliDecode.c index 75eebe86c..6d22c6c4e 100644 --- a/libImaging/FliDecode.c +++ b/libImaging/FliDecode.c @@ -185,7 +185,7 @@ ImagingFliDecode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes) /* COPY chunk */ for (y = 0; y < state->ysize; y++) { UINT8* buf = (UINT8*) im->image[y]; - memcpy(buf+x, data, state->xsize); + memcpy(buf, data, state->xsize); data += state->xsize; } break;