aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-03-31 08:04:57 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-03-31 08:04:57 +0000
commit3eb96ce643d1ee1d11d559b24333a46d54143bdb (patch)
tree1d6a962de14ab6e29c18280ee2322e27c761952d
parent101ac88dc577c04f57475d10ac4f399b3affd308 (diff)
downloadmandoc-3eb96ce643d1ee1d11d559b24333a46d54143bdb.tar.gz
mandoc-3eb96ce643d1ee1d11d559b24333a46d54143bdb.tar.zst
mandoc-3eb96ce643d1ee1d11d559b24333a46d54143bdb.zip
Fixed fatal bug in Xo/Xc patch that caused segfaults with last-child explicit-scope macros.
-rw-r--r--Makefile2
-rw-r--r--mdoc_macro.c23
2 files changed, 15 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index 7561357f..73e1da83 100644
--- a/Makefile
+++ b/Makefile
@@ -13,7 +13,7 @@ INSTALL_MAN = $(INSTALL_DATA)
VERSION = 1.9.21
VDATE = 31 March 2010
-VFLAGS = -DVERSION="\"$(VERSION)\"" -DHAVE_CONFIG_H
+VFLAGS = -DVERSION="\"$(VERSION)\"" -DHAVE_CONFIG_H -DUGLY
WFLAGS = -W -Wall -Wstrict-prototypes -Wno-unused-parameter -Wwrite-strings
CFLAGS += -g $(VFLAGS) $(WFLAGS)
#CFLAGS += -DOSNAME="\"OpenBSD 4.5\""
diff --git a/mdoc_macro.c b/mdoc_macro.c
index 89a4b04d..54c07c33 100644
--- a/mdoc_macro.c
+++ b/mdoc_macro.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_macro.c,v 1.48 2010/03/31 07:42:04 kristaps Exp $ */
+/* $Id: mdoc_macro.c,v 1.49 2010/03/31 08:04:57 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -879,6 +879,7 @@ blk_full(MACRO_PROT_ARGS)
int c, la;
struct mdoc_arg *arg;
struct mdoc_node *head; /* save of head macro */
+ struct mdoc_node *body; /* save of body macro */
#ifdef UGLY
struct mdoc_node *n;
#endif
@@ -923,7 +924,7 @@ blk_full(MACRO_PROT_ARGS)
if ( ! mdoc_block_alloc(m, line, ppos, tok, arg))
return(0);
- head = NULL;
+ head = body = NULL;
/*
* The `Nd' macro has all arguments in its body: it's a hybrid
@@ -938,6 +939,7 @@ blk_full(MACRO_PROT_ARGS)
return(0);
if ( ! mdoc_body_alloc(m, line, ppos, tok))
return(0);
+ body = m->last;
}
for (;;) {
@@ -994,20 +996,23 @@ blk_full(MACRO_PROT_ARGS)
if (1 == ppos && ! append_delims(m, line, pos, buf))
return(0);
- /* See notes on `Nd' hybrid, above. */
+ /* If we've already opened our body, exit now. */
- if (MDOC_Nd == tok)
+ if (NULL != body)
return(1);
#ifdef UGLY
/*
- * If there is an open sub-block requiring explicit close-out,
- * postpone switching the current block from head to body until
- * the rew_sub() call closing out that sub-block.
+ * If there is an open (i.e., unvalidated) sub-block requiring
+ * explicit close-out, postpone switching the current block from
+ * head to body until the rew_sub() call closing out that
+ * sub-block.
*/
for (n = m->last; n && n != head; n = n->parent) {
- if (MDOC_EXPLICIT & mdoc_macros[n->tok].flags &&
- MDOC_BLOCK == n->type) {
+ if (MDOC_BLOCK == n->type &&
+ MDOC_EXPLICIT & mdoc_macros[n->tok].flags &&
+ ! (MDOC_VALID & n->flags)) {
+ assert( ! (MDOC_ACTED & n->flags));
n->pending = head;
return(1);
}