From 92f5030b799f6020fedee4405064884b3fd1051d Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 17 Feb 2025 10:48:18 -0600 Subject: [PATCH] dont try to set pixels outside of bounds --- adafruit_imageload/png.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/adafruit_imageload/png.py b/adafruit_imageload/png.py index 010dff3..0c5892f 100644 --- a/adafruit_imageload/png.py +++ b/adafruit_imageload/png.py @@ -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