From 0d731c6aa0966ad15cb7e2c6158df5bff07c9f41 Mon Sep 17 00:00:00 2001 From: Brian Ashworth Date: Thu, 28 Feb 2019 12:16:56 -0500 Subject: [PATCH] parse_text: return if next is UTF8_INVALID In the underscore case, the next character is retrieved to check whether the underscore is at a word break. However, if this character is UTF8_INVALID, the call to parser_pushch will be a noop. This results in the loop continuing on further than it should. This just adds a check to see if next is UTF8_INVALID and returns if it is. Signed-off-by: Brian Ashworth --- src/main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main.c b/src/main.c index 5d1892c..211b932 100644 --- a/src/main.c +++ b/src/main.c @@ -219,6 +219,9 @@ static void parse_text(struct parser *p) { } else { utf8_fputch(p->output, ch); } + if (next == UTF8_INVALID) { + return; + } parser_pushch(p, next); break; case '+':