From e1a8b046169323c3d85dc974e1af6e7395737cbb Mon Sep 17 00:00:00 2001 From: Corwin Date: Fri, 19 Apr 2024 23:59:58 +0100 Subject: [PATCH] add bounds check --- agb/src/panics_render/text.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/agb/src/panics_render/text.rs b/agb/src/panics_render/text.rs index d817a06d..6e0026d3 100644 --- a/agb/src/panics_render/text.rs +++ b/agb/src/panics_render/text.rs @@ -54,12 +54,11 @@ impl<'bitmap, 'gba> BitmapTextRender<'bitmap, 'gba> { for y in 0..letter.height as usize { for x in 0..letter.width as usize { let rendered = letter.bit_absolute(x, y); - if rendered { - self.bitmap.draw_point( - x as i32 + self.head_position.x, - y as i32 + y_position_start, - self.colour, - ); + let x = x as i32 + self.head_position.x; + let y = y as i32 + y_position_start; + + if rendered && (0..=WIDTH).contains(&x) && (0..=HEIGHT).contains(&y) { + self.bitmap.draw_point(x, y, self.colour); } } }