summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2017-01-08 18:08:45 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2017-01-08 18:08:45 +0000
commitff75b2ee381bf547525aa8055840ea1fc637c829 (patch)
tree205fbbb9d702b582eda0766399354b44aa232bac /usr.bin
parent41004fbb1d30a1805033f7f516ca23730b35b5ad (diff)
Fix an assertion failure caused by \z\[u00FF] with -Tps/-Tpdf.
Reported by jsg@ after an afl(1) run long ago.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mandoc/term.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/usr.bin/mandoc/term.c b/usr.bin/mandoc/term.c
index 32fa1b67e7c..aa36e557bd0 100644
--- a/usr.bin/mandoc/term.c
+++ b/usr.bin/mandoc/term.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: term.c,v 1.118 2016/08/10 11:02:30 schwarze Exp $ */
+/* $OpenBSD: term.c,v 1.119 2017/01/08 18:08:44 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2010-2016 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -604,8 +604,20 @@ encode(struct termp *p, const char *word, size_t sz)
if (ASCII_HYPH == word[i] ||
isgraph((unsigned char)word[i]))
encode1(p, word[i]);
- else
+ else {
p->buf[p->col++] = word[i];
+
+ /*
+ * Postpone the effect of \z while handling
+ * an overstrike sequence from ascii_uc2str().
+ */
+
+ if (word[i] == '\b' &&
+ (p->flags & TERMP_BACKBEFORE)) {
+ p->flags &= ~TERMP_BACKBEFORE;
+ p->flags |= TERMP_BACKAFTER;
+ }
+ }
}
}