7a7319e4ab2652e0b2b970ebfd85bb0ab8f0e958
1 #! /bin/sh /usr/share/dpatch/dpatch-run
2 ## infiniteloop.dpatch by Jonas Fonseca <fonseca@diku.dk>
3 ##
4 ## DP: add_keybinding: always allocate the new keybinding
5 ## DP:
6 ## DP: Fixes infinite loop repoted by Miciah. Also simply continue when wgetch
7 ## DP: returns ERR (-1) instead of calling get_keybinding() etc.
9 @DPATCH@
11 diff --git a/tig.c b/tig.c
12 index aac7c4e..6c2b7d0 100644
13 --- a/tig.c
14 +++ b/tig.c
15 @@ -767,10 +767,9 @@ static struct keybinding *keybindings[AR
16 static void
17 add_keybinding(enum keymap keymap, enum request request, int key)
18 {
19 - struct keybinding *keybinding = keybindings[keymap];
20 + struct keybinding *keybinding;
22 - if (!keybinding)
23 - keybinding = calloc(1, sizeof(*keybinding));
24 + keybinding = calloc(1, sizeof(*keybinding));
25 if (!keybinding)
26 die("Failed to allocate keybinding");
28 @@ -3532,6 +3531,8 @@ main(int argc, char *argv[])
30 /* Refresh, accept single keystroke of input */
31 key = wgetch(status_win);
32 + if (key == ERR)
33 + continue;
35 request = get_keybinding(display[current_view]->keymap, key);