Fix IndexError in apply_png_predictor for wide scanlines - #1275
Closed
SAY-5 wants to merge 1 commit into
Closed
Conversation
Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
|
This is a duplicate of #1271 |
Author
|
You're right, #1271 has the same fix already in flight. Closing this one in favor of that. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull request
Fixes #1269.
apply_png_predictorseeds the prior row withline_above = bytearray(columns), but a scanline isnbytes = colors * columns * bitspercomponent // 8bytes wide. When that is wider thancolumns(multiple colors, or 8-bit components), the first scanline with filter type 3 (Average) or 4 (Paeth) indexesline_above[j]past its end and raisesIndexError: list index out of range. Seeding it withbytearray(nbytes)gives the spec-mandated full-width zero prior row, matching the width of therawrows used for every later scanline.How Has This Been Tested?
Added
test_apply_png_predictor_multibyte_pixelsintests/test_utils.py, which decodes a 3-color scanline (6 bytes wide, columns=2) with the Average filter and checks the output. It raises the reportedIndexErrorwithout the fix and passes with it. The fulltests/test_utils.pysuite passes andruffis clean.Checklist