From 07c23fbf1756c04667035534ed15344896448dce Mon Sep 17 00:00:00 2001 From: Guldoman Date: Sat, 28 Aug 2021 06:02:12 +0200 Subject: [PATCH] Avoid having no `pixel_width` On small scales `pixel_width` could become `0`. This caused the creation of buffers of size `0` with consequent overflows. --- lib/font_renderer/font_renderer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/font_renderer/font_renderer.cpp b/lib/font_renderer/font_renderer.cpp index 8026a89d..14110107 100644 --- a/lib/font_renderer/font_renderer.cpp +++ b/lib/font_renderer/font_renderer.cpp @@ -245,7 +245,7 @@ FR_Bitmap *FR_Bake_Font_Bitmap(FR_Renderer *font_renderer, int font_height, } const int glyph_avg_width = glyph_count > 0 ? x_size_sum / (glyph_count * subpixel_scale) : font_height; - const int pixels_width = glyph_avg_width * 28; + const int pixels_width = glyph_avg_width > 0 ? glyph_avg_width * 28 : 28; // dry run simulating pixel position to estimate required image's height int x = x_start, y = 0, y_bottom = y;