Merge pull request #5149 from wiredfool/gif_write_oob_read

This commit is contained in:
Hugo van Kemenade 2021-01-02 10:14:17 +02:00 committed by GitHub
commit 07bbc46589
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 6 deletions

View File

@ -74,10 +74,10 @@ def test_optimize():
im.save(test_file, "GIF", optimize=optimize)
return len(test_file.getvalue())
assert test_grayscale(0) == 800
assert test_grayscale(1) == 44
assert test_bilevel(0) == 800
assert test_bilevel(1) == 800
assert test_grayscale(0) == 799
assert test_grayscale(1) == 43
assert test_bilevel(0) == 799
assert test_bilevel(1) == 799
def test_optimize_correctness():

View File

@ -233,8 +233,13 @@ ImagingGifEncode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes)
}
}
this = state->buffer[state->x++];
/* Potential special case for xsize==1 */
if (state->x < state->xsize) {
this = state->buffer[state->x++];
} else {
EMIT_RUN(label0);
break;
}
if (this == context->last) {
context->count++;