aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/lib.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/lib.c b/lib/lib.c
index 55b09b85..22b85b06 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -1013,7 +1013,7 @@ char *getdirname(char *name)
char *s, *ss, *keep;
for (s = name, ss = keep = 0; ; s++) {
- if (!*s) return keep ? xstrndup(name, keep-name) : xstrdup(".");
+ if (!s || !*s) return keep ? xstrndup(name, keep-name) : xstrdup(".");
if (*s != '/') keep = ss;
else if (s == name) keep = ss = s+1;
else if (s[-1] != '/') ss = s;