From: schwarze Date: Tue, 9 Aug 2016 15:08:15 +0000 (+0000) Subject: fix printf("%s", NULL); X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=d37754b9a21724e35a9538bf2d465992441c96f8;p=openbsd fix printf("%s", NULL); found while investigating an unrelated bug report from jsg@ --- diff --git a/usr.bin/mandoc/main.c b/usr.bin/mandoc/main.c index 45f5c52d9f7..c2208c9d0d8 100644 --- a/usr.bin/mandoc/main.c +++ b/usr.bin/mandoc/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.177 2016/08/01 10:32:39 schwarze Exp $ */ +/* $OpenBSD: main.c,v 1.178 2016/08/09 15:08:15 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010-2012, 2014-2016 Ingo Schwarze @@ -955,7 +955,8 @@ mmsg(enum mandocerr t, enum mandoclevel lvl, { const char *mparse_msg; - fprintf(stderr, "%s: %s:", getprogname(), file); + fprintf(stderr, "%s: %s:", getprogname(), + file == NULL ? "" : file); if (line) fprintf(stderr, "%d:%d:", line, col + 1); diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c index 3cb63437c76..41e9920cacc 100644 --- a/usr.bin/mandoc/mdoc_validate.c +++ b/usr.bin/mandoc/mdoc_validate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mdoc_validate.c,v 1.217 2016/01/08 17:48:04 schwarze Exp $ */ +/* $OpenBSD: mdoc_validate.c,v 1.218 2016/08/09 15:08:15 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010-2016 Ingo Schwarze @@ -1764,10 +1764,11 @@ post_sh_head(POST_ARGS) /* The NAME should be first. */ - if (SEC_NAME != sec && SEC_NONE == mdoc->lastnamed) + if (sec != SEC_NAME && mdoc->lastnamed == SEC_NONE) mandoc_vmsg(MANDOCERR_NAMESEC_FIRST, mdoc->parse, - mdoc->last->line, mdoc->last->pos, - "Sh %s", secnames[sec]); + mdoc->last->line, mdoc->last->pos, "Sh %s", + sec == SEC_CUSTOM ? mdoc->last->child->string : + secnames[sec]); /* The SYNOPSIS gets special attention in other areas. */