From 5b5e2179910015a0fdf5b691696334ae0b371ff7 Mon Sep 17 00:00:00 2001 From: Ray Chason Date: Sat, 8 Oct 2022 15:42:07 -0400 Subject: [PATCH] Avoid null dereference in VESA initialization If the VESA mode chooses a mode with 8 bit pixels, but the tile set has too many colors for that, a null dereference can result when trying to set up the nonexistent palette. Catch this condition and refuse to set VESA mode instead. --- sys/msdos/vidvesa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/msdos/vidvesa.c b/sys/msdos/vidvesa.c index 10877b7a6..c09566545 100644 --- a/sys/msdos/vidvesa.c +++ b/sys/msdos/vidvesa.c @@ -1047,7 +1047,7 @@ vesa_Init(void) vesa_mode = 0xFFFF; /* might want an 8 bit mode after loading tiles */ vesa_detect(); - if (vesa_mode == 0xFFFF) { + if (vesa_mode == 0xFFFF || (vesa_pixel_size == 8 && get_palette() == NULL)) { raw_printf("%s (%d)", "Reverting to TTY mode, no VESA mode available.", tilefailure); wait_synch();