1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-29 14:26:39 +02:00

alias: remove check of NULL pointers before calling free() (issue #865)

This commit is contained in:
Sébastien Helleu
2024-04-24 23:12:05 +02:00
parent 4baf0e8526
commit c242c8e3f9
2 changed files with 10 additions and 18 deletions
+1 -2
View File
@@ -221,8 +221,7 @@ alias_command_cb (const void *pointer, void *data,
if (ptr_option)
weechat_config_option_free (ptr_option);
weechat_printf (NULL, _("Alias \"%s\" removed"), name);
if (name)
free (name);
free (name);
}
ptr_alias = ptr_next_alias;
}
+9 -16
View File
@@ -306,8 +306,7 @@ alias_run_command (struct t_gui_buffer **buffer, const char *command)
string = weechat_buffer_string_replace_local_var (*buffer, command);
weechat_command (*buffer,
(string) ? string : command);
if (string)
free (string);
free (string);
/* get new current buffer */
new_current_buffer = weechat_current_buffer ();
@@ -409,8 +408,7 @@ alias_cb (const void *pointer, void *data,
}
}
if (args_replaced)
free (args_replaced);
free (args_replaced);
}
ptr_alias->running = 0;
weechat_string_free_split_command (commands);
@@ -469,10 +467,8 @@ alias_hook_command (struct t_alias *alias)
(str_completion) ? str_completion : alias->completion,
&alias_cb, alias, NULL);
if (str_priority_name)
free (str_priority_name);
if (str_completion)
free (str_completion);
free (str_priority_name);
free (str_completion);
}
/*
@@ -611,12 +607,10 @@ alias_free (struct t_alias *alias)
/* free data */
if (alias->hook)
weechat_unhook (alias->hook);
if (alias->name)
free (alias->name);
if (alias->command)
free (alias->command);
if (alias->completion)
free (alias->completion);
free (alias->name);
free (alias->command);
free (alias->completion);
free (alias);
}
@@ -641,8 +635,7 @@ void
alias_update_completion (struct t_alias *alias, const char *completion)
{
/* update completion in alias */
if (alias->completion)
free (alias->completion);
free (alias->completion);
alias->completion = (completion) ? strdup (completion) : NULL;
/* hook command again, with new completion */