summaryrefslogtreecommitdiffstats
path: root/term_ascii.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-12-19 17:12:04 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-12-19 17:12:04 +0000
commit04a689795a0d5b44eacb81cb022fc4806f18112d (patch)
treeaf09d99e336491cb6e6ea05052770da18d764972 /term_ascii.c
parenta40eca4c1b8dab3da5f695f89a86dcad5b0692b6 (diff)
downloadmandoc-04a689795a0d5b44eacb81cb022fc4806f18112d.tar.gz
Enforcing an arbitrary, implementation dependent, undocumented limit
by calling assert() when valid user input exceeds it is a bad idea. Allocate the terminal font stack dynamically instead of crashing above 10 entries. Issue found by jsg@ with afl.
Diffstat (limited to 'term_ascii.c')
-rw-r--r--term_ascii.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/term_ascii.c b/term_ascii.c
index 94be3597..1231fd87 100644
--- a/term_ascii.c
+++ b/term_ascii.c
@@ -69,6 +69,9 @@ ascii_init(enum termenc enc, const struct mchars *mchars, char *outopts)
p->symtab = mchars;
p->tabwidth = 5;
p->defrmargin = p->lastrmargin = 78;
+ p->fontq = mandoc_reallocarray(NULL,
+ (p->fontsz = 8), sizeof(enum termfont));
+ p->fontq[0] = p->fontl = TERMFONT_NONE;
p->begin = ascii_begin;
p->end = ascii_end;