From 36c2de76df31e89fe730d1099dadb5fc01d913d0 Mon Sep 17 00:00:00 2001 From: Bradley Bell Date: Fri, 12 Dec 2014 16:11:48 -0800 Subject: [PATCH] prevent overflow of line buffer --- main/console.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main/console.c b/main/console.c index 0367746b..c66a98c1 100644 --- a/main/console.c +++ b/main/console.c @@ -511,7 +511,7 @@ void CON_Init() /* Load the dirty rectangle for user input */ console->InputBackground = NULL; - console->VChars = CON_CHARS_PER_LINE; + console->VChars = CON_CHARS_PER_LINE - 1; console->LineBuffer = CON_NUM_LINES; console->ConsoleLines = (char **)d_malloc(sizeof(char *) * console->LineBuffer); @@ -571,8 +571,8 @@ void CON_InitGFX(int w, int h) /* calculate the number of visible characters in the command line */ console->VChars = (w - CON_CHAR_BORDER) / console->ConsoleSurface->cv_font->ft_w; - if(console->VChars > CON_CHARS_PER_LINE) - console->VChars = CON_CHARS_PER_LINE; + if(console->VChars >= CON_CHARS_PER_LINE) + console->VChars = CON_CHARS_PER_LINE - 1; gr_init_bitmap_data(&bmp); pcx_error = pcx_read_bitmap(CON_BG, &bmp, BM_LINEAR, pal); -- 2.39.2