From 2201d6b6803be77a9654dcf097b886a6a6eb261c Mon Sep 17 00:00:00 2001 From: schwarze Date: Thu, 18 Dec 2014 20:58:00 +0000 Subject: [PATCH] Don't let .Ta creep into an already-closed list; same as for .It. Fixes an assertion found by jsg@ with afl. --- regress/usr.bin/mandoc/mdoc/Bl/bareTa.in | 5 +++++ regress/usr.bin/mandoc/mdoc/Bl/bareTa.out_ascii | 3 +++ regress/usr.bin/mandoc/mdoc/Bl/bareTa.out_lint | 1 + usr.bin/mandoc/mdoc_macro.c | 5 +++-- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/regress/usr.bin/mandoc/mdoc/Bl/bareTa.in b/regress/usr.bin/mandoc/mdoc/Bl/bareTa.in index 20f003766a9..12eaf45e21b 100644 --- a/regress/usr.bin/mandoc/mdoc/Bl/bareTa.in +++ b/regress/usr.bin/mandoc/mdoc/Bl/bareTa.in @@ -18,4 +18,9 @@ middle text .It Ta ignored arguments indented text .El +middle text +.Bl -column "a" "b" -offset indent +.It a Ta b +.El +.It ignored arguments final text diff --git a/regress/usr.bin/mandoc/mdoc/Bl/bareTa.out_ascii b/regress/usr.bin/mandoc/mdoc/Bl/bareTa.out_ascii index d1378e08719..831ffee8335 100644 --- a/regress/usr.bin/mandoc/mdoc/Bl/bareTa.out_ascii +++ b/regress/usr.bin/mandoc/mdoc/Bl/bareTa.out_ascii @@ -10,6 +10,9 @@ DDEESSCCRRIIPPTTIIOONN middle text -- indented text + middle text + + a b final text OpenBSD November 12, 2012 OpenBSD diff --git a/regress/usr.bin/mandoc/mdoc/Bl/bareTa.out_lint b/regress/usr.bin/mandoc/mdoc/Bl/bareTa.out_lint index e663e421f8e..141e1bd8a2b 100644 --- a/regress/usr.bin/mandoc/mdoc/Bl/bareTa.out_lint +++ b/regress/usr.bin/mandoc/mdoc/Bl/bareTa.out_lint @@ -2,3 +2,4 @@ mandoc: bareTa.in:9:2: ERROR: skipping column outside column list: Ta mandoc: bareTa.in:13:2: ERROR: skipping column outside column list: Ta mandoc: bareTa.in:18:5: ERROR: skipping column outside column list: Ta mandoc: bareTa.in:18:2: ERROR: skipping all arguments: It ignored arguments +mandoc: bareTa.in:25:2: ERROR: skipping item outside list: It ignored arguments diff --git a/usr.bin/mandoc/mdoc_macro.c b/usr.bin/mandoc/mdoc_macro.c index 3dbd6602e8c..eb4fa301f18 100644 --- a/usr.bin/mandoc/mdoc_macro.c +++ b/usr.bin/mandoc/mdoc_macro.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mdoc_macro.c,v 1.114 2014/12/18 03:09:42 schwarze Exp $ */ +/* $OpenBSD: mdoc_macro.c,v 1.115 2014/12/18 20:58:00 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze @@ -1557,7 +1557,8 @@ phrase_ta(MACRO_PROT_ARGS) /* Make sure we are in a column list or ignore this macro. */ n = mdoc->last; - while (n != NULL && n->tok != MDOC_Bl) + while (n != NULL && + (n->tok != MDOC_Bl || n->flags & (MDOC_VALID | MDOC_BREAK))) n = n->parent; if (n == NULL || n->norm->Bl.type != LIST_column) { mandoc_msg(MANDOCERR_TA_STRAY, mdoc->parse, -- 2.20.1