From f3ff84cd050997434c3d4dd862d1b385a27494c8 Mon Sep 17 00:00:00 2001 From: bunnie Date: Wed, 26 Feb 2025 14:45:31 +0800 Subject: [PATCH] fix off by one in bounds check for display size --- services/cramium-emu/src/display.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/cramium-emu/src/display.rs b/services/cramium-emu/src/display.rs index 3132a7936..839b41f6e 100644 --- a/services/cramium-emu/src/display.rs +++ b/services/cramium-emu/src/display.rs @@ -203,7 +203,7 @@ impl FrameBuffer for Oled128x128 { fn clear(&mut self) { self.buffer_mut().fill(DARK_COLOUR); } fn put_pixel(&mut self, p: Point, on: ColorNative) { - if p.x > COLUMN || p.y > ROW || p.x < 0 || p.y < 0 { + if p.x >= COLUMN || p.y >= ROW || p.x < 0 || p.y < 0 { return; } let buffer = self.buffer_mut(); @@ -213,7 +213,7 @@ impl FrameBuffer for Oled128x128 { fn dimensions(&self) -> Point { Point::new(COLUMN, ROW) } fn get_pixel(&mut self, p: Point) -> Option { - if p.x > COLUMN || p.y > ROW || p.x < 0 || p.y < 0 { + if p.x >= COLUMN || p.y >= ROW || p.x < 0 || p.y < 0 { return None; } let buffer = self.buffer(); @@ -222,7 +222,7 @@ impl FrameBuffer for Oled128x128 { } fn xor_pixel(&mut self, p: Point) { - if p.x > COLUMN || p.y > ROW || p.x < 0 || p.y < 0 { + if p.x >= COLUMN || p.y >= ROW || p.x < 0 || p.y < 0 { return; } let buffer = self.buffer_mut();