summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2016-08-09 15:09:27 +0000
committerIngo Schwarze <schwarze@openbsd.org>2016-08-09 15:09:27 +0000
commitc3d32c57947c93990ff1080f2a1c0a0cec64d559 (patch)
tree7cc632cba91206166420e507140874ffa90d1f71
parent1bb4f8bb9e7406c14961365a652ce2e16ab7664c (diff)
downloadmandoc-c3d32c57947c93990ff1080f2a1c0a0cec64d559.tar.gz
fix printf("%s", NULL);
found while investigating an unrelated bug report from jsg@
-rw-r--r--main.c3
-rw-r--r--mdoc_validate.c7
2 files changed, 6 insertions, 4 deletions
diff --git a/main.c b/main.c
index 12f4c995..ebf08a4c 100644
--- a/main.c
+++ b/main.c
@@ -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 ? "<stdin>" : file);
if (line)
fprintf(stderr, "%d:%d:", line, col + 1);
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 8614a15a..6a39419e 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -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. */