1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-26 12:56:37 +02:00

Fix unlikely memory leak in function gui_keyboard_new

This commit is contained in:
Sebastien Helleu
2011-01-06 14:34:53 +01:00
parent 7dbc797789
commit f7b473790b
+5 -1
View File
@@ -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;
}