From 327ba4d7676807137f3ba3026d1d55f0b17a9bfd Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Mon, 20 Apr 2015 09:48:53 +0000 Subject: 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. --- mdoc_validate.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mdoc_validate.c b/mdoc_validate.c index 1df68760..272c23aa 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_validate.c,v 1.289 2015/04/19 14:25:41 schwarze Exp $ */ +/* $Id: mdoc_validate.c,v 1.290 2015/04/20 09:48:53 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010-2015 Ingo Schwarze @@ -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) -- cgit v1.2.3-56-ge451