From 55ffd41892040f7ae1ac2eb11731e6d8b4bad28b Mon Sep 17 00:00:00 2001 From: anon Date: Wed, 20 Sep 2023 22:43:12 +0200 Subject: [PATCH] dont segfault on empty token "match" --- source/terminal.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/source/terminal.c b/source/terminal.c index 1583279..a028c45 100644 --- a/source/terminal.c +++ b/source/terminal.c @@ -16,11 +16,13 @@ void cterm_render_callback(const char * const string, } terminal_hl_t * term_hl = (terminal_hl_t*)attributes; - if (term_hl->attribute) { - fputs(term_hl->attribute, stdout); - } - if (term_hl->foreground_color) { - fputs(term_hl->foreground_color, stdout); + if (term_hl) { + if (term_hl->attribute) { + fputs(term_hl->attribute, stdout); + } + if (term_hl->foreground_color) { + fputs(term_hl->foreground_color, stdout); + } } for (int i = 0; i < length; i++) { putchar(*(string+i));