summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-03-29 19:45:42 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-03-29 19:45:42 +0000
commit8e0ae69291c882caad421f15bf201442fa3fc512 (patch)
tree26d1a7310381db9d9f9b6509cd6158f894b6feb3
parent32a41d48b41f86a02e6bcc4c4ce9f4ead3f42b06 (diff)
downloadmandoc-8e0ae69291c882caad421f15bf201442fa3fc512.tar.gz
mandoc-8e0ae69291c882caad421f15bf201442fa3fc512.tar.zst
mandoc-8e0ae69291c882caad421f15bf201442fa3fc512.zip
Fixed segfault with accidentally-munged tree.
-rw-r--r--mdoc_macro.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/mdoc_macro.c b/mdoc_macro.c
index fbb2509f..2d38744f 100644
--- a/mdoc_macro.c
+++ b/mdoc_macro.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_macro.c,v 1.43 2010/03/29 19:28:04 kristaps Exp $ */
+/* $Id: mdoc_macro.c,v 1.44 2010/03/29 19:45:42 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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