mirror of
https://github.com/tmate-io/tmate.git
synced 2025-03-15 08:38:53 +01:00
Sync OpenBSD patchset 411:
cmd_find_client shouldn't die when there is an empty slot in the clients array. DOH.
This commit is contained in:
parent
3d88da7b2a
commit
8085adb8a2
17
cmd.c
17
cmd.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmd.c,v 1.124 2009-10-14 13:22:24 nicm Exp $ */
|
/* $Id: cmd.c,v 1.125 2009-10-15 01:56:45 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -398,7 +398,7 @@ cmd_newest_client(void)
|
|||||||
struct client *
|
struct client *
|
||||||
cmd_find_client(struct cmd_ctx *ctx, const char *arg)
|
cmd_find_client(struct cmd_ctx *ctx, const char *arg)
|
||||||
{
|
{
|
||||||
struct client *c;
|
struct client *c, *lastc;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
char *tmparg;
|
char *tmparg;
|
||||||
size_t arglen;
|
size_t arglen;
|
||||||
@ -414,16 +414,17 @@ cmd_find_client(struct cmd_ctx *ctx, const char *arg)
|
|||||||
*/
|
*/
|
||||||
s = cmd_current_session(ctx);
|
s = cmd_current_session(ctx);
|
||||||
if (s != NULL) {
|
if (s != NULL) {
|
||||||
c = NULL;
|
lastc = NULL;
|
||||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
if (ARRAY_ITEM(&clients, i)->session == s) {
|
c = ARRAY_ITEM(&clients, i);
|
||||||
if (c != NULL)
|
if (c != NULL && c->session == s) {
|
||||||
|
if (lastc != NULL)
|
||||||
break;
|
break;
|
||||||
c = ARRAY_ITEM(&clients, i);
|
lastc = c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i == ARRAY_LENGTH(&clients) && c != NULL)
|
if (i == ARRAY_LENGTH(&clients) && lastc != NULL)
|
||||||
return (c);
|
return (lastc);
|
||||||
}
|
}
|
||||||
return (cmd_newest_client());
|
return (cmd_newest_client());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user