summaryrefslogtreecommitdiff
path: root/src/man.c
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-04-15 16:09:53 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2015-04-15 16:11:12 -0700
commit520d5a6fc6a6cf100d9414d588079f2a076801c5 (patch)
treeb77d9b219515d227f48b4cbfa5af67641e99d9b8 /src/man.c
parent8c121939e21f6ebb57e33a2e2e4bf90d37a0a140 (diff)
Check return status of utf8proc_iterate. Closes #27.
If unicode parsing gives an error condition, we just skip the rest of the string without rendering anything and proceed. I'm not sure if that's the best way to handle this, but garbage in, garbage out. Note: this bug was found using american fuzzy lop.
Diffstat (limited to 'src/man.c')
-rw-r--r--src/man.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/man.c b/src/man.c
index 27cd2e4..8ff4a9f 100644
--- a/src/man.c
+++ b/src/man.c
@@ -20,6 +20,9 @@ static void escape_man(cmark_strbuf *dest, const unsigned char *source, int leng
while (i < length) {
len = utf8proc_iterate(source + i, length - i, &c);
+ if (len == -1) { // error condition
+ return; // return without rendering anything
+ }
switch(c) {
case 46:
if (beginLine) {