From f7b473790bededac5c5d0bf4326caecb47d2f343 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Thu, 6 Jan 2011 14:34:53 +0100 Subject: Fix unlikely memory leak in function gui_keyboard_new --- src/gui/gui-keyboard.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/gui-keyboard.c b/src/gui/gui-keyboard.c index 435b136d5..0e308eed9 100644 --- a/src/gui/gui-keyboard.c +++ b/src/gui/gui-keyboard.c @@ -314,6 +314,9 @@ gui_keyboard_new (struct t_gui_buffer *buffer, const char *key, struct t_gui_key *new_key; char *expanded_name; + if (!key || !command) + return NULL; + if ((new_key = malloc (sizeof (*new_key)))) { new_key->key = gui_keyboard_get_internal_code (key); @@ -324,9 +327,10 @@ gui_keyboard_new (struct t_gui_buffer *buffer, const char *key, free (new_key); return NULL; } - new_key->command = (command) ? strdup (command) : NULL; + new_key->command = strdup (command); if (!new_key->command) { + free (new_key->key); free (new_key); return NULL; } -- cgit v1.2.3