summaryrefslogtreecommitdiffstats
path: root/term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2017-01-08 18:16:58 +0000
committerIngo Schwarze <schwarze@openbsd.org>2017-01-08 18:16:58 +0000
commit6c7378e60ac7c58a6240de9ec382c4f1da4e8e4f (patch)
tree7c3b2c99fe05c57c9e55782a41b6fce5ee0ec99a /term.c
parent3bf55aeff70f65d3415839875bf2c1a0ff205a31 (diff)
downloadmandoc-6c7378e60ac7c58a6240de9ec382c4f1da4e8e4f.tar.gz
Fix an assertion failure caused by \z\[u00FF] with -Tps/-Tpdf.
Reported by jsg@ after an afl(1) run long ago.
Diffstat (limited to 'term.c')
-rw-r--r--term.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/term.c b/term.c
index 65ca6ffa..28a26951 100644
--- a/term.c
+++ b/term.c
@@ -1,7 +1,7 @@
/* $Id$ */
/*
* 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
@@ -606,8 +606,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;
+ }
+ }
}
}