From: Jonas Fonseca Date: Thu, 28 Sep 2006 11:51:38 +0000 (+0200) Subject: add_keybinding: always allocate the new keybinding X-Git-Tag: tig-0.6~4^2~5 X-Git-Url: https://git.distorted.org.uk/~mdw/tig/commitdiff_plain/8b534a13651f1416d368bcc10b496ca189c2ca0c add_keybinding: always allocate the new keybinding Fixes infinite loop repoted by Miciah. Also simply continue when wgetch returns ERR (-1) instead of calling get_keybinding() etc. --- diff --git a/tig.c b/tig.c index aac7c4e..6c2b7d0 100644 --- a/tig.c +++ b/tig.c @@ -767,10 +767,9 @@ static struct keybinding *keybindings[ARRAY_SIZE(keymap_table)]; static void add_keybinding(enum keymap keymap, enum request request, int key) { - struct keybinding *keybinding = keybindings[keymap]; + struct keybinding *keybinding; - if (!keybinding) - keybinding = calloc(1, sizeof(*keybinding)); + keybinding = calloc(1, sizeof(*keybinding)); if (!keybinding) die("Failed to allocate keybinding"); @@ -3532,6 +3531,8 @@ main(int argc, char *argv[]) /* Refresh, accept single keystroke of input */ key = wgetch(status_win); + if (key == ERR) + continue; request = get_keybinding(display[current_view]->keymap, key);