From dadc3a61401b8f8bb2df584ab32d18a799c7f0ec Mon Sep 17 00:00:00 2001 From: schwarze Date: Tue, 19 Aug 2014 17:28:57 +0000 Subject: [PATCH] Do not dereference a NULL pointer if a .Bl macro has no -type, -width, -offset or -compact arguments whatsoever; this got broken in mdoc_validate.c rev. 1.156. While here, sort headers. --- regress/usr.bin/mandoc/mdoc/Bl/notype.in | 12 ++++++++++-- regress/usr.bin/mandoc/mdoc/Bl/notype.out_ascii | 10 ++++++++-- regress/usr.bin/mandoc/mdoc/Bl/notype.out_lint | 3 ++- usr.bin/mandoc/mdoc_validate.c | 8 ++++---- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/regress/usr.bin/mandoc/mdoc/Bl/notype.in b/regress/usr.bin/mandoc/mdoc/Bl/notype.in index d28a5b0d82f..dce46bf80ba 100644 --- a/regress/usr.bin/mandoc/mdoc/Bl/notype.in +++ b/regress/usr.bin/mandoc/mdoc/Bl/notype.in @@ -5,14 +5,22 @@ .Nm Bl-notype .Nd lists with late or missing types .Sh DESCRIPTION -initial text +late type: .Bl -offset indent -bullet .It Some text. .El tail argument -middle text +.Pp +no type: .Bl -offset indent .It Some text. .El +.Pp +no argument at all: +.Bl +.It +Some text. +.El +.Pp final text diff --git a/regress/usr.bin/mandoc/mdoc/Bl/notype.out_ascii b/regress/usr.bin/mandoc/mdoc/Bl/notype.out_ascii index 02a9960338a..2bb4d069f56 100644 --- a/regress/usr.bin/mandoc/mdoc/Bl/notype.out_ascii +++ b/regress/usr.bin/mandoc/mdoc/Bl/notype.out_ascii @@ -4,12 +4,18 @@ NNAAMMEE BBll--nnoottyyppee - lists with late or missing types DDEESSCCRRIIPPTTIIOONN - initial text + late type: oo Some text. - middle text + + no type: Some text. + + no argument at all: + + Some text. + final text OpenBSD July 4, 2014 OpenBSD diff --git a/regress/usr.bin/mandoc/mdoc/Bl/notype.out_lint b/regress/usr.bin/mandoc/mdoc/Bl/notype.out_lint index ec90ae56602..c14bd0b46be 100644 --- a/regress/usr.bin/mandoc/mdoc/Bl/notype.out_lint +++ b/regress/usr.bin/mandoc/mdoc/Bl/notype.out_lint @@ -1,3 +1,4 @@ mandoc: notype.in:9:2: WARNING: list type is not the first argument: Bl -offset mandoc: notype.in:12:2: ERROR: skipping all arguments: El tail argument -mandoc: notype.in:14:2: ERROR: missing list type, using -item: Bl +mandoc: notype.in:15:2: ERROR: missing list type, using -item: Bl +mandoc: notype.in:21:2: ERROR: missing list type, using -item: Bl diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c index fcca5e06f0a..0612989d5db 100644 --- a/usr.bin/mandoc/mdoc_validate.c +++ b/usr.bin/mandoc/mdoc_validate.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_validate.c,v 1.161 2014/08/08 16:17:09 schwarze Exp $ */ +/* $Id: mdoc_validate.c,v 1.162 2014/08/19 17:28:57 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010-2014 Ingo Schwarze @@ -16,12 +16,12 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +#include #ifndef OSNAME #include #endif -#include - #include #include #include @@ -528,7 +528,7 @@ pre_bl(PRE_ARGS) * ones. If we find no list type, we default to LIST_item. */ - wa = n->args->argv; + wa = (n->args == NULL) ? NULL : n->args->argv; mdoclt = MDOC_ARG_MAX; for (i = 0; n->args && i < (int)n->args->argc; i++) { argv = n->args->argv + i; -- 2.20.1