Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guard against out of bounds pixel set #96

Merged
merged 1 commit into from
Feb 18, 2025

Conversation

FoamyGuy
Copy link
Contributor

Resolves: #95

I've tested successfully with the image file in the issue, as well as all PNGs included in the examples directory in this repo all on a PyPortal Titano 9.2.4

@FoamyGuy FoamyGuy requested a review from a team February 17, 2025 16:58
Copy link
Member

@jepler jepler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this makes sense (say you have width = 31 (valid x coordinates 0..30 inclusive) and pixels_per_byte = 2. You will reach the point where x + pixel is 31, causing an IndexError on old line 116....

There don't seem to be any tests of png loading. perhaps there should be some.

@FoamyGuy
Copy link
Contributor Author

I started writing a test for this, but it turns out that the Blinka DisplayIO implementation of Bitmap does not raise an IndexError if you attempt to set pixels outside of it's size so the test passes even in what would be a failure case on the microcontroller. Once a change is made in Blinka Displayio to align it with core we can have a test here will effectively check for this and ensure it stays working.

@FoamyGuy FoamyGuy merged commit c5e3b7e into adafruit:main Feb 18, 2025
1 check passed
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IndexError with some PNG files
2 participants