summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2009-10-14 20:52:29 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2009-10-14 20:52:29 +0000
commitb6601794a3e3b5f17205ccc2f9bebd7888790ce3 (patch)
tree5c41233ea0dd4b7d562f003da70962a67fa785b0 /usr.bin
parent7bb207d43928ce0281f521d0b2011a959c9e1738 (diff)
cmd_find_client shouldn't die when there is an empty slot in the clients
array. DOH.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/cmd.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/usr.bin/tmux/cmd.c b/usr.bin/tmux/cmd.c
index 6bb4e9fe94f..1796626c757 100644
--- a/usr.bin/tmux/cmd.c
+++ b/usr.bin/tmux/cmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd.c,v 1.25 2009/10/14 09:29:10 nicm Exp $ */
+/* $OpenBSD: cmd.c,v 1.26 2009/10/14 20:52:28 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -399,7 +399,7 @@ cmd_newest_client(void)
struct client *
cmd_find_client(struct cmd_ctx *ctx, const char *arg)
{
- struct client *c;
+ struct client *c, *lastc;
struct session *s;
char *tmparg;
size_t arglen;
@@ -415,16 +415,17 @@ cmd_find_client(struct cmd_ctx *ctx, const char *arg)
*/
s = cmd_current_session(ctx);
if (s != NULL) {
- c = NULL;
+ lastc = NULL;
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
- if (ARRAY_ITEM(&clients, i)->session == s) {
- if (c != NULL)
+ c = ARRAY_ITEM(&clients, i);
+ if (c != NULL && c->session == s) {
+ if (lastc != NULL)
break;
- c = ARRAY_ITEM(&clients, i);
+ lastc = c;
}
}
- if (i == ARRAY_LENGTH(&clients) && c != NULL)
- return (c);
+ if (i == ARRAY_LENGTH(&clients) && lastc != NULL)
+ return (lastc);
}
return (cmd_newest_client());
}