Code

add_keybinding: plug memory leak
authorJonas Fonseca <fonseca@diku.dk>
Sun, 17 Sep 2006 19:52:28 +0000 (21:52 +0200)
committerJonas Fonseca <fonseca@antimatter.localdomain>
Sun, 17 Sep 2006 22:26:01 +0000 (00:26 +0200)
tig.c

diff --git a/tig.c b/tig.c
index de85ca1652056c317615cbd95efb3ce6dedd5dc7..3397489437fca65c549f4563e9af224f04a30a47 100644 (file)
--- 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");