summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2020-04-09 13:54:39 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2020-04-09 13:54:39 +0000
commit1fdad6347e22272bb8a487c69b3f5a1b742ddcfe (patch)
treefc323126ff347b3350c0f9569c88a9de7e443330 /usr.bin
parentb4953475cbf893cf2905f60aed8ecc9018503915 (diff)
Do not try to use the client if the item containing it is NULL.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/cmd-find.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/usr.bin/tmux/cmd-find.c b/usr.bin/tmux/cmd-find.c
index a84c34d9127..2e24e357704 100644
--- a/usr.bin/tmux/cmd-find.c
+++ b/usr.bin/tmux/cmd-find.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-find.c,v 1.73 2019/06/12 09:10:29 nicm Exp $ */
+/* $OpenBSD: cmd-find.c,v 1.74 2020/04/09 13:54:38 nicm Exp $ */
/*
* Copyright (c) 2015 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -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. */