fixed potential buffer overflow
authorHolger Schemel <holger.schemel@virtion.de>
Sat, 12 Oct 2024 19:13:56 +0000 (21:13 +0200)
committerHolger Schemel <holger.schemel@virtion.de>
Sat, 12 Oct 2024 19:13:56 +0000 (21:13 +0200)
src/libgame/text.c

index 04893897598075ebd9309927d16d3c8eb6db02ea..2d2d43e02c55cd9f8d498615f2dca66323be8b63 100644 (file)
@@ -554,8 +554,8 @@ static void setTextBufferCharSize(int *line_length, int *cut_length, int *max_li
   int font_height = getFontHeight(font_nr);
   int line_height = font_height + line_spacing;
 
-  *line_length = line_width / font_width;
-  *cut_length  = cut_width  / font_width;
+  *line_length = MIN(line_width / font_width, MAX_OUTPUT_LINESIZE);
+  *cut_length  = MIN(cut_width  / font_width, MAX_OUTPUT_LINESIZE);
   *max_lines   = max_height / line_height;
 }