summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2016-08-11 10:47:16 +0000
committerIngo Schwarze <schwarze@openbsd.org>2016-08-11 10:47:16 +0000
commit2ed7335d7c5c3402584fdef6e3847eb2af331d76 (patch)
tree74cc48a8744ca0f22909b18ee7401a82ad9d4ec6
parent1a424591f0d787caa06b72793aca04d086543797 (diff)
downloadmandoc-2ed7335d7c5c3402584fdef6e3847eb2af331d76.tar.gz
If a .Bd display is on the one hand doomed to be deleted because
it has no type, but is on the other hand breaking another block, delete its end marker as well, or the end marker may remain behind as an orphan, triggering an assertion in the terminal formatter. Problem found by tb@ with afl(1).
-rw-r--r--mdoc_validate.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 48d1fd0f..1a36052a 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -886,9 +886,10 @@ post_display(POST_ARGS)
n = mdoc->last;
switch (n->type) {
case ROFFT_BODY:
- if (n->end != ENDBODY_NOT)
- break;
- if (n->child == NULL)
+ if (n->end != ENDBODY_NOT) {
+ if (n->tok == MDOC_Bd && n->parent->args == NULL)
+ roff_node_delete(mdoc, n);
+ } else if (n->child == NULL)
mandoc_msg(MANDOCERR_BLK_EMPTY, mdoc->parse,
n->line, n->pos, mdoc_macronames[n->tok]);
else if (n->tok == MDOC_D1)