From 43d904dbf396f5ce90e29915b416fd26e32c6c3e Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Mon, 4 Mar 2013 09:02:32 +0000 Subject: [PATCH] tty.path can be NULL, don't dereference it. From George Nachman. --- cmd-choose-client.c | 2 +- cmd.c | 8 ++++---- 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;