summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/cmd.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2009-10-14 20:52:28 +0000
committernicm <nicm@openbsd.org>2009-10-14 20:52:28 +0000
commit9fa5094f8039d9286896f073c5e97b1f6e9d59c6 (patch)
tree8ad5b787a9a7f41f91b6fa207e95ba1554fb9b50 /usr.bin/tmux/cmd.c
parentsort flags. (diff)
downloadwireguard-openbsd-9fa5094f8039d9286896f073c5e97b1f6e9d59c6.tar.xz
wireguard-openbsd-9fa5094f8039d9286896f073c5e97b1f6e9d59c6.zip
cmd_find_client shouldn't die when there is an empty slot in the clients
array. DOH.
Diffstat (limited to 'usr.bin/tmux/cmd.c')
-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());
}