diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2017-09-12 18:21:03 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2017-09-12 18:21:03 +0000 |
commit | 8aeee8c83fca34072d530314dc724856ca46e74c (patch) | |
tree | fa455714df2f5fa90671c66e865009c379c9d68c /mdoc_validate.c | |
parent | b99b10fd0c42fb887260394bc4de5ca7e60d4a9a (diff) | |
download | mandoc-8aeee8c83fca34072d530314dc724856ca46e74c.tar.gz |
Do not segfault when there are two .Dt macros, the first without
an architecture argument and the second with an invalid one.
Bug found by jsg@ with afl(1).
Diffstat (limited to 'mdoc_validate.c')
-rw-r--r-- | mdoc_validate.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/mdoc_validate.c b/mdoc_validate.c index fe238eef..a14cb9d0 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -1914,7 +1914,10 @@ post_root(POST_ARGS) arch++; if (*arch == NULL) { n = mdoc->first->child; - while (n->tok != MDOC_Dt) + while (n->tok != MDOC_Dt || + n->child == NULL || + n->child->next == NULL || + n->child->next->next == NULL) n = n->next; n = n->child->next->next; mandoc_vmsg(MANDOCERR_ARCH_BAD, |