aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/man.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-05-07 14:14:17 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-05-07 14:14:17 +0000
commite9fa61ef565b232a81f24582132198563730fbcc (patch)
treeff3ff927158bc16521ab259341494674d1e8b772 /man.c
parentb770d7afd08231270f0fb23c286e8111f65903ec (diff)
downloadmandoc-e9fa61ef565b232a81f24582132198563730fbcc.tar.gz
mandoc-e9fa61ef565b232a81f24582132198563730fbcc.tar.zst
mandoc-e9fa61ef565b232a81f24582132198563730fbcc.zip
Do not segfault in makewhatis -Q if the next .SH after .SH NAME
does not have any arguments. Crash found by nigel@ in kermit(1).
Diffstat (limited to 'man.c')
-rw-r--r--man.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/man.c b/man.c
index 272b1e6e..ac69d176 100644
--- a/man.c
+++ b/man.c
@@ -1,4 +1,4 @@
-/* $Id: man.c,v 1.129 2014/04/20 16:46:04 schwarze Exp $ */
+/* $Id: man.c,v 1.130 2014/05/07 14:14:17 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -595,9 +595,12 @@ man_pmacro(struct man *man, int ln, char *buf, int offs)
/* In quick mode (for mandocdb), abort after the NAME section. */
- if (man->quick && MAN_SH == tok &&
- strcmp(man->last->prev->child->string, "NAME"))
- return(2);
+ if (man->quick && MAN_SH == tok) {
+ n = man->last;
+ if (MAN_BODY == n->type &&
+ strcmp(n->prev->child->string, "NAME"))
+ return(2);
+ }
/*
* We weren't in a block-line scope when entering the