aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuldoman <giulio.lettieri@gmail.com>2021-08-28 06:02:12 +0200
committerFrancesco <francesco.bbt@gmail.com>2021-08-28 09:59:36 +0200
commit07c23fbf1756c04667035534ed15344896448dce (patch)
tree684324611a0106e275ac346c6298b45a338e31cb
parentc7d044f178f44fb802a6fc7cad7c627071b82c3b (diff)
downloadlite-xl-07c23fbf1756c04667035534ed15344896448dce.tar.gz
lite-xl-07c23fbf1756c04667035534ed15344896448dce.zip
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.
-rw-r--r--lib/font_renderer/font_renderer.cpp2
1 files changed, 1 insertions, 1 deletions
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;