summaryrefslogtreecommitdiffstats
path: root/usr.bin/mandoc/mdoc_macro.c
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2011-01-16 19:27:25 +0000
committerschwarze <schwarze@openbsd.org>2011-01-16 19:27:25 +0000
commit5e94b7898efbd3d1b10792a6387e29c818c37011 (patch)
treeaca0ea7fcb9143bca57c3da28c04a8bfc013fe4e /usr.bin/mandoc/mdoc_macro.c
parentsync (diff)
downloadwireguard-openbsd-5e94b7898efbd3d1b10792a6387e29c818c37011.tar.xz
wireguard-openbsd-5e94b7898efbd3d1b10792a6387e29c818c37011.zip
Some improvements to error handling from kristaps@:
* Make out-of-context .fi invocations not cause an error, but just a warning. * Downgrade -man message about ignored empty paragraph to MANDOC_IGNPAR. * Avoid syntax tree corruption when removing empty block macros. Triggered by some reports from brad@.
Diffstat (limited to 'usr.bin/mandoc/mdoc_macro.c')
-rw-r--r--usr.bin/mandoc/mdoc_macro.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/usr.bin/mandoc/mdoc_macro.c b/usr.bin/mandoc/mdoc_macro.c
index 699ebbb92f6..a638ed9445c 100644
--- a/usr.bin/mandoc/mdoc_macro.c
+++ b/usr.bin/mandoc/mdoc_macro.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_macro.c,v 1.62 2011/01/04 22:28:17 schwarze Exp $ */
+/* $Id: mdoc_macro.c,v 1.63 2011/01/16 19:27:25 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -248,17 +248,24 @@ lookup_raw(const char *p)
static int
rew_last(struct mdoc *mdoc, const struct mdoc_node *to)
{
- struct mdoc_node *n;
+ struct mdoc_node *n, *np;
assert(to);
mdoc->next = MDOC_NEXT_SIBLING;
/* LINTED */
while (mdoc->last != to) {
+ /*
+ * Save the parent here, because we may delete the
+ * m->last node in the post-validation phase and reset
+ * it to m->last->parent, causing a step in the closing
+ * out to be lost.
+ */
+ np = mdoc->last->parent;
if ( ! mdoc_valid_post(mdoc))
return(0);
n = mdoc->last;
- mdoc->last = mdoc->last->parent;
+ mdoc->last = np;
assert(mdoc->last);
mdoc->last->last = n;
}