Roger-random / ESP_8_BIT_composite

Color composite video code from ESP_8_BIT as an Arduino library
MIT License
125 stars 15 forks source link

Negative X or Y coordinates cause core panic #7

Closed Roger-random closed 3 years ago

Roger-random commented 3 years ago

Bug in version 1.0.0 found by @emilyvelasco

My code originally used unsigned integers, where negative numbers were impossible by definition. So for bounds checking it only checked the high end, that X did not exceed 255 and Y did not exceed 239.

When it was adapted to use signed integers in conformance to Adafruit GFX declarations, negative numbers became possible, but there were no checks to ensure X and Y were positive numbers.

Using negative coordinates would then step outside of allocated frame buffer memory, an access violation causing core panic.

Roger-random commented 3 years ago

Fixed by new clampX() and clampY() methods in 0a1abcc1bc13aa6d3955c0a3850d5bc7f57e7f4a