summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Lai <ray@cvs.openbsd.org>2009-06-02 11:19:00 +0000
committerRay Lai <ray@cvs.openbsd.org>2009-06-02 11:19:00 +0000
commitfc05ad7288235d80f6cec35e8e4f5cac0da9452d (patch)
treeb7c697322b15bd73464eb819774a7c199dd6c216
parent73fcd9853954ed9ac9221f8f45e6aca98d8279a5 (diff)
Don't access array[-1] if array is an empty string.
OK nicm@
-rw-r--r--usr.bin/tmux/arg.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.bin/tmux/arg.c b/usr.bin/tmux/arg.c
index 47603b3a405..e45a5887a0e 100644
--- a/usr.bin/tmux/arg.c
+++ b/usr.bin/tmux/arg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: arg.c,v 1.1 2009/06/01 22:58:49 nicm Exp $ */
+/* $OpenBSD: arg.c,v 1.2 2009/06/02 11:18:59 ray Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -76,7 +76,7 @@ arg_parse_client(const char *arg)
/* Trim a trailing : if any from the argument. */
n = strlen(arg2);
- if (arg2[n - 1] == ':')
+ if (n && arg2[n - 1] == ':')
arg2[n - 1] = '\0';
/* Try and look up the client name. */
@@ -101,7 +101,7 @@ arg_parse_session(const char *arg)
/* Trim a trailing : if any from the argument. */
n = strlen(arg2);
- if (arg2[n - 1] == ':')
+ if (n && arg2[n - 1] == ':')
arg2[n - 1] = '\0';
/* See if the argument matches a session. */