diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2011-01-06 14:34:53 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2011-01-06 14:34:53 +0100 |
commit | f7b473790bededac5c5d0bf4326caecb47d2f343 (patch) | |
tree | f325af534851645704be3840ffd017d7993d2594 /src/gui | |
parent | 7dbc797789a5211191bcdc96ec3a411d3f70fa00 (diff) | |
download | weechat-f7b473790bededac5c5d0bf4326caecb47d2f343.zip |
Fix unlikely memory leak in function gui_keyboard_new
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/gui-keyboard.c | 6 |
1 files changed, 5 insertions, 1 deletions
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; } |