aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2013-03-04 09:02:32 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2013-03-04 09:02:32 +0000
commit43d904dbf396f5ce90e29915b416fd26e32c6c3e (patch)
tree192a95643e1327515e1dd8da568d2d3905b10cec
parent1da64bf786d2f139b822bc80ef6043443c0ea720 (diff)
downloadrtmux-43d904dbf396f5ce90e29915b416fd26e32c6c3e.tar.gz
rtmux-43d904dbf396f5ce90e29915b416fd26e32c6c3e.tar.bz2
rtmux-43d904dbf396f5ce90e29915b416fd26e32c6c3e.zip
tty.path can be NULL, don't dereference it. From George Nachman.
-rw-r--r--cmd-choose-client.c2
-rw-r--r--cmd.c8
2 files changed, 5 insertions, 5 deletions
diff --git a/cmd-choose-client.c b/cmd-choose-client.c
index ce569ff4..40752a70 100644
--- a/cmd-choose-client.c
+++ b/cmd-choose-client.c
@@ -79,7 +79,7 @@ cmd_choose_client_exec(struct cmd *self, struct cmd_q *cmdq)
cur = idx = 0;
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
c1 = ARRAY_ITEM(&clients, i);
- if (c1 == NULL || c1->session == NULL)
+ if (c1 == NULL || c1->session == NULL || c1->tty.path == NULL)
continue;
if (c1 == cmdq->client)
cur = idx;
diff --git a/cmd.c b/cmd.c
index f3326df2..0d6a85ff 100644
--- a/cmd.c
+++ b/cmd.c
@@ -326,9 +326,9 @@ cmd_current_session(struct cmd_q *cmdq, int prefer_unattached)
return (c->session);
/*
- * If the name of the calling client's pty is know, build a list of the
- * sessions that contain it and if any choose either the first or the
- * newest.
+ * If the name of the calling client's pty is known, build a list of
+ * the sessions that contain it and if any choose either the first or
+ * the newest.
*/
path = c == NULL ? NULL : c->tty.path;
if (path != NULL) {
@@ -531,7 +531,7 @@ cmd_lookup_client(const char *name)
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
c = ARRAY_ITEM(&clients, i);
- if (c == NULL || c->session == NULL)
+ if (c == NULL || c->session == NULL || c->tty.path == NULL)
continue;
path = c->tty.path;