summaryrefslogtreecommitdiffstats
path: root/demandoc.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2015-02-07 06:28:08 +0000
committerIngo Schwarze <schwarze@openbsd.org>2015-02-07 06:28:08 +0000
commitf94c59bbe7eb707afda950ba464d3d0c2b94be7d (patch)
tree1635b53c0fd4bb792aa61cf289cd9efaf4e95e13 /demandoc.c
parent1e390373a2e27a0047fae8db8c21d17e044c8376 (diff)
downloadmandoc-f94c59bbe7eb707afda950ba464d3d0c2b94be7d.tar.gz
be more careful about argc == 0
Diffstat (limited to 'demandoc.c')
-rw-r--r--demandoc.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/demandoc.c b/demandoc.c
index 5a5369fc..7e7ff49a 100644
--- a/demandoc.c
+++ b/demandoc.c
@@ -47,8 +47,9 @@ main(int argc, char *argv[])
int ch, fd, i, list;
extern int optind;
- progname = strrchr(argv[0], '/');
- if (progname == NULL)
+ if (argc < 1)
+ progname = "demandoc";
+ else if ((progname = strrchr(argv[0], '/')) == NULL)
progname = argv[0];
else
++progname;
@@ -81,7 +82,7 @@ main(int argc, char *argv[])
mp = mparse_alloc(MPARSE_SO, MANDOCLEVEL_BADARG, NULL, mchars, NULL);
assert(mp);
- if (0 == argc)
+ if (argc < 1)
pmandoc(mp, STDIN_FILENO, "<stdin>", list);
for (i = 0; i < argc; i++) {