summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2015-04-29 21:58:32 +0000
committerIngo Schwarze <schwarze@openbsd.org>2015-04-29 21:58:32 +0000
commitdb2bae06bdf2e69756cd08658f1032139adcfaea (patch)
tree0d592dddb81050ecfe10582845755a52db719d41
parentc7573bb09a210ded3f9d982b74618c8ca065c367 (diff)
downloadmandoc-db2bae06bdf2e69756cd08658f1032139adcfaea.tar.gz
If a block body gets broken, that's no good reason to extend the
scope of the end macro. Instead, only keep the tail scope open if the end macro macro calls an explicit macro and actually breaks that. This corrects syntax tree structure and fixes an assertion found by jsg@ with afl (test case 098/Apr27).
-rw-r--r--mdoc_macro.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/mdoc_macro.c b/mdoc_macro.c
index 0ac00cd8..a9e65dc1 100644
--- a/mdoc_macro.c
+++ b/mdoc_macro.c
@@ -673,6 +673,8 @@ blk_exp_close(MACRO_PROT_ARGS)
if (endbody != NULL)
n = endbody;
+
+ ntok = TOKEN_NONE;
for (j = 0; ; j++) {
lastarg = *pos;
@@ -700,7 +702,7 @@ blk_exp_close(MACRO_PROT_ARGS)
}
if (n != NULL) {
- if (n != mdoc->last && n->flags & MDOC_BROKEN) {
+ if (ntok != TOKEN_NONE && n->flags & MDOC_BROKEN) {
target = n;
do
target = target->parent;