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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user