aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Lai <ray@openbsd.org>2009-06-02 11:18:59 +0000
committerRay Lai <ray@openbsd.org>2009-06-02 11:18:59 +0000
commitf60bc7e03bc54f8170ca8eca325e14d31fe01a3a (patch)
tree5e42ca3c3ed2202f0c683a88894b20072e335894
parent49c776ea59c9af4ad5e2d1af3b93712ee6534abe (diff)
downloadrtmux-f60bc7e03bc54f8170ca8eca325e14d31fe01a3a.tar.gz
rtmux-f60bc7e03bc54f8170ca8eca325e14d31fe01a3a.tar.bz2
rtmux-f60bc7e03bc54f8170ca8eca325e14d31fe01a3a.zip
Don't access array[-1] if array is an empty string.
OK nicm@
-rw-r--r--arg.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/arg.c b/arg.c
index c02b2663..6fe36a15 100644
--- a/arg.c
+++ b/arg.c
@@ -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. */