From 43b096bd694a056f170794ecbe616e5a7b2ceb68 Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Sat, 12 Oct 2024 20:40:11 +0200 Subject: [PATCH] fix out of bounds read --- src/font.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/font.rs b/src/font.rs index 266a6bb..2600a6c 100644 --- a/src/font.rs +++ b/src/font.rs @@ -10,7 +10,7 @@ use servicepoint::{Grid, PixelGrid, TILE_SIZE}; const DEFAULT_FONT_FILE: &[u8] = include_bytes!("../Web437_IBM_BIOS.woff"); pub struct BitmapFont { - bitmaps: [PixelGrid; u8::MAX as usize], + bitmaps: [PixelGrid; u8::MAX as usize + 1], } impl BitmapFont { @@ -18,7 +18,7 @@ impl BitmapFont { let mut bitmaps = core::array::from_fn(|_| PixelGrid::new(TILE_SIZE, TILE_SIZE)); - for char_code in u8::MIN..u8::MAX { + for char_code in u8::MIN..=u8::MAX { let char = char_code as char; let glyph_id = match font.glyph_for_char(char) { None => continue,