]> git.xolatile.top Git - public-libhl.git/commitdiff
dont segfault on empty token "match"
authoranon <anon@anon.anon>
Wed, 20 Sep 2023 20:43:12 +0000 (22:43 +0200)
committeranon <anon@anon.anon>
Wed, 20 Sep 2023 20:43:12 +0000 (22:43 +0200)
source/terminal.c

index 15832799b2132d7d24c1dd4b9c3d9c5fbc1fbaa4..a028c45737e444845ef512a1efa275889eff52ba 100644 (file)
@@ -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));