diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2017-01-08 18:16:58 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2017-01-08 18:16:58 +0000 |
commit | ba15fe5a9c8e3a3851506453220bacfec09c8ff5 (patch) | |
tree | 21f785f1c55851ba1bb176f6a22087a825fcbce9 /term.c | |
parent | c09bc6817f6a2f70602d1ce88b22a23941750b8c (diff) | |
download | mandoc-ba15fe5a9c8e3a3851506453220bacfec09c8ff5.tar.gz mandoc-ba15fe5a9c8e3a3851506453220bacfec09c8ff5.tar.zst mandoc-ba15fe5a9c8e3a3851506453220bacfec09c8ff5.zip |
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.c | 18 |
1 files changed, 15 insertions, 3 deletions
@@ -1,7 +1,7 @@ -/* $Id: term.c,v 1.258 2016/08/10 11:03:43 schwarze Exp $ */ +/* $Id: term.c,v 1.259 2017/01/08 18:16:58 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 @@ -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; + } + } } } |