Skip to content

Commit 9cf9c4c

Browse files
committed
Fix width/height bound checks in stage-3 logger
1 parent 74ead92 commit 9cf9c4c

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

bios/stage-3/src/screen.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,13 @@ impl ScreenWriter {
7474
'\n' => self.newline(),
7575
'\r' => self.carriage_return(),
7676
c => {
77-
if self.x_pos >= self.width() {
77+
let bitmap_char = get_bitmap(c, FontWeight::Regular, BitmapHeight::Size14).unwrap();
78+
if self.x_pos + bitmap_char.width() > self.width() {
7879
self.newline();
7980
}
80-
const BITMAP_LETTER_WIDTH: usize =
81-
get_bitmap_width(FontWeight::Regular, BitmapHeight::Size14);
82-
if self.y_pos >= (self.height() - BITMAP_LETTER_WIDTH) {
81+
if self.y_pos + bitmap_char.height() > self.height() {
8382
self.clear();
8483
}
85-
let bitmap_char = get_bitmap(c, FontWeight::Regular, BitmapHeight::Size14).unwrap();
8684
self.write_rendered_char(bitmap_char);
8785
}
8886
}

0 commit comments

Comments
 (0)