diff options
author | Tiago Cunha <tcunha@gmx.com> | 2010-07-02 02:43:01 +0000 |
---|---|---|
committer | Tiago Cunha <tcunha@gmx.com> | 2010-07-02 02:43:01 +0000 |
commit | 03c1c1cd9f731a8a5a066855077e91e31d2baf34 (patch) | |
tree | 832957257356595b9739132bd7d72aeea410f7a7 /key-bindings.c | |
parent | 0e70c8801cc4143b9100c860df1f2e3aac368d0a (diff) | |
download | rtmux-03c1c1cd9f731a8a5a066855077e91e31d2baf34.tar.gz rtmux-03c1c1cd9f731a8a5a066855077e91e31d2baf34.tar.bz2 rtmux-03c1c1cd9f731a8a5a066855077e91e31d2baf34.zip |
Sync OpenBSD patchset 727:
Setting the cmdlist pointer in the bind-key to NULL to prevent it being freed
after the command is executing is bogus because it may still be needed if the
same command is going to be executed again (for example if you "bind-key a
bind-key b ..."). Making a copy is hard, so instead add a reference count to
the cmd_list.
While here, also print bind-key -n and the rest of the flags properly.
Fixes problem reported by mcbride@.
Diffstat (limited to 'key-bindings.c')
-rw-r--r-- | key-bindings.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/key-bindings.c b/key-bindings.c index 7f4a9576..f799b399 100644 --- a/key-bindings.c +++ b/key-bindings.c @@ -1,4 +1,4 @@ -/* $Id: key-bindings.c,v 1.93 2010-06-22 23:35:20 tcunha Exp $ */ +/* $Id: key-bindings.c,v 1.94 2010-07-02 02:43:01 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -178,14 +178,15 @@ key_bindings_init(void) for (i = 0; i < nitems(table); i++) { cmdlist = xmalloc(sizeof *cmdlist); - TAILQ_INIT(cmdlist); + TAILQ_INIT(&cmdlist->list); + cmdlist->references = 1; cmd = xmalloc(sizeof *cmd); cmd->entry = table[i].entry; cmd->data = NULL; if (cmd->entry->init != NULL) cmd->entry->init(cmd, table[i].key); - TAILQ_INSERT_HEAD(cmdlist, cmd, qentry); + TAILQ_INSERT_HEAD(&cmdlist->list, cmd, qentry); key_bindings_add( table[i].key | KEYC_PREFIX, table[i].can_repeat, cmdlist); @@ -259,7 +260,7 @@ key_bindings_dispatch(struct key_binding *bd, struct client *c) ctx.cmdclient = NULL; readonly = 1; - TAILQ_FOREACH(cmd, bd->cmdlist, qentry) { + TAILQ_FOREACH(cmd, &bd->cmdlist->list, qentry) { if (!(cmd->entry->flags & CMD_READONLY)) readonly = 0; } |