Don't access array[-1] if array is an empty string.

OK nicm@
pull/1/head
Ray Lai 2009-06-02 11:18:59 +00:00
parent 49c776ea59
commit f60bc7e03b
1 changed files with 2 additions and 2 deletions

4
arg.c
View File

@ -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. */