diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2012-11-16 13:25:35 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2012-11-16 13:25:35 +0000 |
commit | 29ddff189eb5f07acf055b54da17db91acb021ae (patch) | |
tree | 79ecff245934165bc44712ea3ffb4ad822662460 /usr.bin | |
parent | 4f86f1aaa9552e3869177c2e5e63ca8a627b46cc (diff) |
Fix a crash triggered by .Bl -tag .It Xo .El .Sh found by florian@.
* When allocating a body end marker, copy the pointer to the normalized
block information from the body block, avoiding the risk of subsequent
null pointer derefence.
* When inserting the body end marker into the syntax tree, do not try to
copy that pointer from the parent block, because not being a direkt child
of the block it belongs to is the whole point of a body end marker.
* Even non-callable blocks (like Bd and Bl) can break other blocks;
when this happens, postpone closing them out in the usual way.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/mandoc/mdoc.c | 5 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_macro.c | 4 |
2 files changed, 6 insertions, 3 deletions
diff --git a/usr.bin/mandoc/mdoc.c b/usr.bin/mandoc/mdoc.c index 9ffc5dab783..c5171c49d66 100644 --- a/usr.bin/mandoc/mdoc.c +++ b/usr.bin/mandoc/mdoc.c @@ -1,4 +1,4 @@ -/* $Id: mdoc.c,v 1.91 2012/07/18 11:09:30 schwarze Exp $ */ +/* $Id: mdoc.c,v 1.92 2012/11/16 13:25:34 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2012 Ingo Schwarze <schwarze@openbsd.org> @@ -371,6 +371,8 @@ node_append(struct mdoc *mdoc, struct mdoc_node *p) switch (p->type) { case (MDOC_BODY): + if (ENDBODY_NOT != p->end) + break; /* FALLTHROUGH */ case (MDOC_TAIL): /* FALLTHROUGH */ @@ -497,6 +499,7 @@ mdoc_endbody_alloc(struct mdoc *m, int line, int pos, enum mdoct tok, p = node_alloc(m, line, pos, tok, MDOC_BODY); p->pending = body; + p->norm = body->norm; p->end = end; if ( ! node_append(m, p)) return(0); diff --git a/usr.bin/mandoc/mdoc_macro.c b/usr.bin/mandoc/mdoc_macro.c index ea0af8c83d7..18493ae5282 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.74 2012/07/18 16:20:14 schwarze Exp $ */ +/* $Id: mdoc_macro.c,v 1.75 2012/11/16 13:25:34 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2012 Ingo Schwarze <schwarze@openbsd.org> @@ -734,7 +734,7 @@ blk_exp_close(MACRO_PROT_ARGS) if (later && MDOC_EXPLICIT & mdoc_macros[later->tok].flags) continue; - if (MDOC_CALLABLE & mdoc_macros[n->tok].flags) + if (MDOC_It != n->tok) later = n; } |