From 8b534a13651f1416d368bcc10b496ca189c2ca0c Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Thu, 28 Sep 2006 13:51:38 +0200 Subject: [PATCH] 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. --- tig.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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); -- 2.32.0.93.g670b81a890