From 6737b893e3198eb8acb1647742d46a6c58cf3c30 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Tue, 9 Aug 2016 15:09:27 +0000 Subject: fix printf("%s", NULL); found while investigating an unrelated bug report from jsg@ --- main.c | 5 +++-- mdoc_validate.c | 9 +++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/main.c b/main.c index 56bfd635..e240719b 100644 --- a/main.c +++ b/main.c @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.274 2016/07/19 21:31:55 schwarze Exp $ */ +/* $Id: main.c,v 1.275 2016/08/09 15:09:27 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010-2012, 2014-2016 Ingo Schwarze @@ -985,7 +985,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/mdoc_validate.c b/mdoc_validate.c index e369349c..80ce2080 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_validate.c,v 1.301 2016/01/08 17:48:09 schwarze Exp $ */ +/* $Id: mdoc_validate.c,v 1.302 2016/08/09 15:09:27 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010-2016 Ingo Schwarze @@ -1773,10 +1773,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. */ -- cgit v1.2.3-56-ge451