Skip to content

Commit

Permalink
Merge pull request #96 from FoamyGuy/indexerror_fix
Browse files Browse the repository at this point in the history
Guard against out of bounds pixel set
  • Loading branch information
FoamyGuy authored Feb 18, 2025
2 parents 95b5c09 + 92f5030 commit c5e3b7e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion adafruit_imageload/png.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ def load( # noqa: PLR0912, PLR0915, Too many branches, Too many statements
for x in range(0, width, pixels_per_byte):
byte = data_bytes[src_b]
for pixel in range(pixels_per_byte):
bmp[x + pixel, y] = (byte >> ((pixels_per_byte - pixel - 1) * depth)) & pixmask
if x + pixel < width:
bmp[x + pixel, y] = (
byte >> ((pixels_per_byte - pixel - 1) * depth)
) & pixmask
src_b += 1
src += scanline + 1
src_b = src
Expand Down

0 comments on commit c5e3b7e

Please sign in to comment.