From abc048e3c43ecb25293a29437dc907f21727a5b2 Mon Sep 17 00:00:00 2001 From: Ryan Steinmetz Date: Wed, 4 Jul 2018 11:59:55 -0400 Subject: [PATCH] Fix crash when font is missing a character --- tdfiglet.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tdfiglet.c b/tdfiglet.c index b5b8960..ef34938 100644 --- a/tdfiglet.c +++ b/tdfiglet.c @@ -491,7 +491,13 @@ printstr(const char *str, font_t *font) } for (int c = 0; c < strlen(str); c++) { - glyph_t *g = font->glyphs[lookupchar(str[c], font)]; + int id = lookupchar(str[c], font); + + if (id == -1) { + continue; + } + + glyph_t *g = font->glyphs[id]; printrow(g, i); if (opt.color == COLOR_ANSI) {