From 45c11bcafa11459f35bb66354fa2c0053791519d Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Mon, 29 Mar 2010 19:45:42 +0000 Subject: Fixed segfault with accidentally-munged tree. --- mdoc_macro.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/mdoc_macro.c b/mdoc_macro.c index 56e8ad20..4dbe8d81 100644 --- a/mdoc_macro.c +++ b/mdoc_macro.c @@ -904,10 +904,10 @@ blk_full(MACRO_PROT_ARGS) if ( ! mdoc_block_alloc(m, line, ppos, tok, arg)) return(0); + if ( ! mdoc_head_alloc(m, line, ppos, tok)) + return(0); - if (0 == buf[*pos]) { - if ( ! mdoc_head_alloc(m, line, ppos, tok)) - return(0); + if ('\0' == buf[*pos]) { if ( ! rew_sub(MDOC_HEAD, m, tok, line, ppos)) return(0); if ( ! mdoc_body_alloc(m, line, ppos, tok)) @@ -915,9 +915,6 @@ blk_full(MACRO_PROT_ARGS) return(1); } - if ( ! mdoc_head_alloc(m, line, ppos, tok)) - return(0); - /* Immediately close out head and enter body, if applicable. */ if (0 == dohead) { @@ -1051,10 +1048,11 @@ blk_part_imp(MACRO_PROT_ARGS) /* Clean-ups to leave in a consistent state. */ - if (NULL == body && ! mdoc_body_alloc(m, line, ppos, tok)) - return(0); - - body = m->last; + if (NULL == body) { + if ( ! mdoc_body_alloc(m, line, ppos, tok)) + return(0); + body = m->last; + } /* * If we can't rewind to our body, then our scope has already -- cgit