summaryrefslogtreecommitdiff
path: root/usr.bin/mg/cscope.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/mg/cscope.c')
-rw-r--r--usr.bin/mg/cscope.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/usr.bin/mg/cscope.c b/usr.bin/mg/cscope.c
index 02fca962aa1..d84ec7faa1f 100644
--- a/usr.bin/mg/cscope.c
+++ b/usr.bin/mg/cscope.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cscope.c,v 1.15 2016/01/19 11:39:06 sunil Exp $ */
+/* $OpenBSD: cscope.c,v 1.16 2016/01/19 14:51:00 sunil Exp $ */
/*
* This file is in the public domain.
@@ -614,7 +614,7 @@ csexists(const char *cmd)
continue;
dlen = strlen(dir);
- while (dir[dlen-1] == '/')
+ while (dlen > 0 && dir[dlen-1] == '/')
dir[--dlen] = '\0'; /* strip trailing '/' */
len = snprintf(fname, sizeof(fname), "%s/%s", dir, cmd);