summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2011-11-19 13:17:45 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2011-11-19 13:17:45 +0000
commit7c8094a3ac439b9d9cd5ef5c0d77744db2544287 (patch)
tree3a24988dd73a66fb1c87705cdfae7316d3eb893f /usr.bin
parent899bb23a0a1e04ba5e7d8b42f111d6db7acb2f32 (diff)
Avoid a NULL pointer access if an .Rs block body contains nothing
but invalid nodes. Output still differs a lot from groff, but at least let's not crash. Problem found and patch provided by joerg@, thanks!
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mandoc/mdoc_validate.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c
index 9d8827d4b97..f3e3479a329 100644
--- a/usr.bin/mandoc/mdoc_validate.c
+++ b/usr.bin/mandoc/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.97 2011/11/16 19:47:58 schwarze Exp $ */
+/* $Id: mdoc_validate.c,v 1.98 2011/11/19 13:17:44 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -1690,6 +1690,14 @@ post_rs(POST_ARGS)
}
/*
+ * Nothing to sort if only invalid nodes were found
+ * inside the `Rs' body.
+ */
+
+ if (NULL == mdoc->last->child)
+ return(1);
+
+ /*
* The full `Rs' block needs special handling to order the
* sub-elements according to `rsord'. Pick through each element
* and correctly order it. This is a insertion sort.