Merge pull request #2813 from wiredfool/issue_2811

Permit LZW code lengths up to 12 bits in GIF decode
This commit is contained in:
wiredfool 2017-11-05 15:02:41 +00:00 committed by GitHub
commit f5e4338b86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 1 deletions

BIN
Tests/images/issue_2811.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

@ -546,6 +546,13 @@ class TestFileGif(PillowTestCase):
finally:
GifImagePlugin._FORCE_OPTIMIZE = False
def test_lzw_bits(self):
# see https://github.com/python-pillow/Pillow/issues/2811
im = Image.open('Tests/images/issue_2811.gif')
self.assertEqual(im.tile[0][3][0], 11) # LZW bits
# codec error prepatch
im.load()
if __name__ == '__main__':
unittest.main()

View File

@ -71,7 +71,7 @@ ImagingGifDecode(Imaging im, ImagingCodecState state, UINT8* buffer, int bytes)
if (!state->state) {
/* Initialise state */
if (context->bits < 0 || context->bits > 8) {
if (context->bits < 0 || context->bits > 12) {
state->errcode = IMAGING_CODEC_CONFIG;
return -1;
}