summaryrefslogtreecommitdiffstats
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
commitb9c525e48989511fbf504fe170eb6ba6231845fb (patch)
treec6ca7bf26cc738b6fb761d3a0a154353c7d04cde /man.c
parent1a3508134c2d35578a77bd0e53a064ada6d757a5 (diff)
downloadmandoc-b9c525e48989511fbf504fe170eb6ba6231845fb.tar.gz
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.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/man.c b/man.c
index 1ad78a55..374f50e9 100644
--- a/man.c
+++ b/man.c
@@ -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