aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-11-29 23:15:54 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-11-29 23:15:54 +0000
commit8274e3e03443f69f30987361b470638167aa963b (patch)
tree0e0d6bb27635534e77498ec9947241fa20a774e7
parentvt: fix memory corruption: wcwidth() may return -1 (diff)
font: never set glyph->cols to something that is less than 0
-rw-r--r--font.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/font.c b/font.c
index e1c8b73d..9094b794 100644
--- a/font.c
+++ b/font.c
@@ -648,10 +648,13 @@ glyph_for_wchar(const struct font *font, wchar_t wc, struct glyph *glyph)
pixman_image_set_filter(pix, PIXMAN_FILTER_BEST, NULL, 0);
}
+ int cols = wcwidth(wc);
+ if (cols < 0)
+ cols = 0;
*glyph = (struct glyph){
.wc = wc,
- .cols = wcwidth(wc),
+ .cols = cols,
.pix = pix,
.x = font->face->glyph->bitmap_left * font->pixel_size_fixup,
.y = font->face->glyph->bitmap_top * font->pixel_size_fixup,