summaryrefslogtreecommitdiffstats
path: root/mdoc_validate.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2015-04-20 09:48:53 +0000
committerIngo Schwarze <schwarze@openbsd.org>2015-04-20 09:48:53 +0000
commit3ee436ab2a46363611bf798816b6330a09d9b68e (patch)
tree54365b924d7261c2ac7d311d7a4e09be1e695a9e /mdoc_validate.c
parentadb61c0917d43d6cf61cc003e0b829293f796ec6 (diff)
downloadmandoc-3ee436ab2a46363611bf798816b6330a09d9b68e.tar.gz
Avoid out-of-bounds read access before the beginning of the
mdoc_macros[] array. This sometimes prevented proper warnings about text nodes preceding the first section header.
Diffstat (limited to 'mdoc_validate.c')
-rw-r--r--mdoc_validate.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/mdoc_validate.c b/mdoc_validate.c
index dd477eef..616e9b10 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1562,7 +1562,8 @@ post_root(POST_ARGS)
/* Check that we begin with a proper `Sh'. */
n = mdoc->first->child;
- while (n != NULL && mdoc_macros[n->tok].flags & MDOC_PROLOGUE)
+ while (n != NULL && n->tok != TOKEN_NONE &&
+ mdoc_macros[n->tok].flags & MDOC_PROLOGUE)
n = n->next;
if (n == NULL)