diff options
author | nicm <nicm> | 2020-04-09 13:54:38 +0000 |
---|---|---|
committer | nicm <nicm> | 2020-04-09 13:54:38 +0000 |
commit | 5288801d3e2e06b97bda336835491c11eb8f9f76 (patch) | |
tree | 12110e90a674d27ec2cc76001042a4f17fcd494d | |
parent | 315961faeceefae30d3fcce28c3171fdec7e5c5d (diff) | |
download | rtmux-5288801d3e2e06b97bda336835491c11eb8f9f76.tar.gz rtmux-5288801d3e2e06b97bda336835491c11eb8f9f76.tar.bz2 rtmux-5288801d3e2e06b97bda336835491c11eb8f9f76.zip |
Do not try to use the client if the item containing it is NULL.
-rw-r--r-- | cmd-find.c | 22 |
1 files changed, 12 insertions, 10 deletions
@@ -1231,29 +1231,31 @@ no_pane: static struct client * cmd_find_current_client(struct cmdq_item *item, int quiet) { - struct client *c; + struct client *c = NULL, *found; struct session *s; struct window_pane *wp; struct cmd_find_state fs; - if (item->client != NULL && item->client->session != NULL) - return (item->client); + if (item != NULL) + c = item->client; + if (c != NULL && c->session != NULL) + return (c); - c = NULL; - if ((wp = cmd_find_inside_pane(item->client)) != NULL) { + found = NULL; + if (c != NULL && (wp = cmd_find_inside_pane(c)) != NULL) { cmd_find_clear_state(&fs, CMD_FIND_QUIET); fs.w = wp->window; if (cmd_find_best_session_with_window(&fs) == 0) - c = cmd_find_best_client(fs.s); + found = cmd_find_best_client(fs.s); } else { s = cmd_find_best_session(NULL, 0, CMD_FIND_QUIET); if (s != NULL) - c = cmd_find_best_client(s); + found = cmd_find_best_client(s); } - if (c == NULL && !quiet) + if (found == NULL && item != NULL && !quiet) cmdq_error(item, "no current client"); - log_debug("%s: no target, return %p", __func__, c); - return (c); + log_debug("%s: no target, return %p", __func__, found); + return (found); } /* Find the target client or report an error and return NULL. */ |