From: Jonas Fonseca Date: Sun, 17 Sep 2006 19:52:28 +0000 (+0200) Subject: add_keybinding: plug memory leak X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=32553785b929e5d9f5da012b555291fff2824640;p=tig.git add_keybinding: plug memory leak --- diff --git a/tig.c b/tig.c index de85ca1..3397489 100644 --- a/tig.c +++ b/tig.c @@ -767,9 +767,10 @@ static struct keybinding *keybindings[ARRAY_SIZE(keymap_table)]; static void add_keybinding(enum keymap keymap, enum request request, int key) { - struct keybinding *keybinding; + struct keybinding *keybinding = keybindings[keymap]; - keybinding = calloc(1, sizeof(*keybinding)); + if (!keybinding) + keybinding = calloc(1, sizeof(*keybinding)); if (!keybinding) die("Failed to allocate keybinding");