PicoGraphics: Fix overflow bug in p4 pixel span.

A properly aligned zero length pixel span would cause a single
pixel to be drawn, the length overflowed and a subsequent
2GB of pixels drawn by the main loop.

Add a simple check to discard any attempt to draw zero length spans.

Fixes pimoroni/pimoroni-pico-rp2350#32
pull/1049/head
Phil Howard 2025-01-14 12:16:02 +00:00
rodzic a90abba9db
commit 19689b4414
1 zmienionych plików z 4 dodań i 0 usunięć

Wyświetl plik

@ -70,6 +70,10 @@ namespace pimoroni {
} }
void PicoGraphics_PenP4::set_pixel_span(const Point &p, uint l) { void PicoGraphics_PenP4::set_pixel_span(const Point &p, uint l) {
// prevent a zero length span causing an overflow in 'l'
// and trying to write 2GB of pixels.
if (l == 0) {return;}
auto i = (p.x + p.y * bounds.w); auto i = (p.x + p.y * bounds.w);
// pointer to byte in framebuffer that contains this pixel // pointer to byte in framebuffer that contains this pixel