From: schwarze Date: Wed, 7 May 2014 14:11:24 +0000 (+0000) Subject: Do not segfault in makewhatis -Q if the next .SH after .SH NAME X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=4c84596f10a705a51731a1e03ab5d3113db3df09;p=openbsd 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). --- diff --git a/usr.bin/mandoc/man.c b/usr.bin/mandoc/man.c index c85e04b6fb6..e29d1ea03c6 100644 --- a/usr.bin/mandoc/man.c +++ b/usr.bin/mandoc/man.c @@ -1,4 +1,4 @@ -/* $Id: man.c,v 1.79 2014/04/20 16:44:44 schwarze Exp $ */ +/* $Id: man.c,v 1.80 2014/05/07 14:11:24 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2013, 2014 Ingo Schwarze @@ -591,9 +591,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