[PATCH] cmdq_add_message: fix segfault accessing c->name

13 views
Skip to first unread message

Thomas Adam

unread,
May 6, 2020, 7:35:09 PM5/6/20
to tmux-...@googlegroups.com, Thomas Adam
The client can be NULL, so don't try and access c->name before we've
checked if the client is not NULL.
---
cmd-queue.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/cmd-queue.c b/cmd-queue.c
index 077599fb..26e2f2f9 100644
--- a/cmd-queue.c
+++ b/cmd-queue.c
@@ -540,11 +540,12 @@ cmdq_add_message(struct cmdq_item *item)
{
struct client *c = item->client;
struct cmdq_state *state = item->state;
- const char *name = c->name, *key;
+ const char *name, *key;
char *tmp;

tmp = cmd_print(item->cmd);
if (c != NULL) {
+ name = c->name;
if (c->session != NULL && state->event.key != KEYC_NONE) {
key = key_string_lookup_key(state->event.key);
server_add_message("%s key %s: %s", name, key, tmp);
--
2.26.1

Reply all
Reply to author
Forward
0 new messages