From 2004c9dca1f8ac89197303b626b518ba19e2be82 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Tue, 15 Apr 2014 00:41:09 +0000 Subject: Using macros in .Sh header lines, or having .Sm off or .Bk -words open while processing .Sh, is not at all recommended, but it's not strictly a syntax violation either, and in any case, mandoc must not die in an assertion. I broke this in rev. 1.124. Crash found while trying to read the (rather broken) original 4.3BSD-Reno od(1) manual page. --- mdoc_validate.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'mdoc_validate.c') diff --git a/mdoc_validate.c b/mdoc_validate.c index ce5c6f27..8c8d06f6 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_validate.c,v 1.208 2014/03/31 01:05:32 schwarze Exp $ */ +/* $Id: mdoc_validate.c,v 1.209 2014/04/15 00:41:09 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010-2014 Ingo Schwarze @@ -1950,7 +1950,7 @@ static int post_sh_head(POST_ARGS) { struct mdoc_node *n; - const char *secname; + char *secname; enum mdoc_sec sec; /* @@ -1962,15 +1962,8 @@ post_sh_head(POST_ARGS) secname = NULL; sec = SEC_CUSTOM; - n = mdoc->last; - if (n->child) { - assert(1 == n->nchild); - n = n->child; - assert(NULL != n); - assert(MDOC_TEXT == n->type); - secname = n->string; - sec = a2sec(secname); - } + mdoc_deroff(&secname, mdoc->last); + sec = NULL == secname ? SEC_CUSTOM : a2sec(secname); /* The NAME should be first. */ @@ -2007,8 +2000,10 @@ post_sh_head(POST_ARGS) /* We don't care about custom sections after this. */ - if (SEC_CUSTOM == sec) + if (SEC_CUSTOM == sec) { + free(secname); return(1); + } /* * Check whether our non-custom section is being repeated or is @@ -2052,6 +2047,7 @@ post_sh_head(POST_ARGS) break; } + free(secname); return(1); } -- cgit v1.2.3-56-ge451