From 32553785b929e5d9f5da012b555291fff2824640 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Sun, 17 Sep 2006 21:52:28 +0200 Subject: [PATCH] add_keybinding: plug memory leak --- tig.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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"); -- 2.30.2