summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/mdoc_validate.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2014-04-15 00:41:03 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2014-04-15 00:41:03 +0000
commit22a9171fe5119f8cea0ab1afc0880cc498ade735 (patch)
tree4036809e7bd9cda2d3e5b7b98dad694922145c60 /usr.bin/mandoc/mdoc_validate.c
parent95eaa6e4c674e5d558b1d1a3a7d8fe205fed0010 (diff)
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.
Diffstat (limited to 'usr.bin/mandoc/mdoc_validate.c')
-rw-r--r--usr.bin/mandoc/mdoc_validate.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c
index 0986ef42fd5..f507a5f9065 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.126 2014/03/31 00:02:45 dlg Exp $ */
+/* $Id: mdoc_validate.c,v 1.127 2014/04/15 00:41:02 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -1946,7 +1946,7 @@ static int
post_sh_head(POST_ARGS)
{
struct mdoc_node *n;
- const char *secname;
+ char *secname;
enum mdoc_sec sec;
/*
@@ -1958,15 +1958,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. */
@@ -2003,8 +1996,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
@@ -2048,6 +2043,7 @@ post_sh_head(POST_ARGS)
break;
}
+ free(secname);
return(1);
}