Skip to content

Commit 19689b4

Browse files
committed
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
1 parent a90abba commit 19689b4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

libraries/pico_graphics/pico_graphics_pen_p4.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ namespace pimoroni {
7070
}
7171

7272
void PicoGraphics_PenP4::set_pixel_span(const Point &p, uint l) {
73+
// prevent a zero length span causing an overflow in 'l'
74+
// and trying to write 2GB of pixels.
75+
if (l == 0) {return;}
76+
7377
auto i = (p.x + p.y * bounds.w);
7478

7579
// pointer to byte in framebuffer that contains this pixel

0 commit comments

Comments
 (0)