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

plugins: remove check of NULL pointers before calling weechat_config_option_free() (issue #865)

This commit is contained in:
Sébastien Helleu
2024-04-25 19:23:22 +02:00
parent 619b40b42f
commit 561dd92d8e
7 changed files with 11 additions and 19 deletions
+4 -8
View File
@@ -52,16 +52,14 @@ alias_command_add (const char *alias_name, const char *command,
ptr_option = weechat_config_search_option (alias_config_file,
alias_config_section_cmd,
alias_name);
if (ptr_option)
weechat_config_option_free (ptr_option);
weechat_config_option_free (ptr_option);
alias_config_cmd_new_option (alias_name, command);
/* create configuration option for completion */
ptr_option = weechat_config_search_option (alias_config_file,
alias_config_section_completion,
alias_name);
if (ptr_option)
weechat_config_option_free (ptr_option);
weechat_config_option_free (ptr_option);
if (completion)
alias_config_completion_new_option (alias_name, completion);
@@ -212,14 +210,12 @@ alias_command_cb (const void *pointer, void *data,
alias_config_file,
alias_config_section_cmd,
ptr_alias_name);
if (ptr_option)
weechat_config_option_free (ptr_option);
weechat_config_option_free (ptr_option);
ptr_option = weechat_config_search_option (
alias_config_file,
alias_config_section_completion,
ptr_alias_name);
if (ptr_option)
weechat_config_option_free (ptr_option);
weechat_config_option_free (ptr_option);
weechat_printf (NULL, _("Alias \"%s\" removed"), name);
free (name);
}
+1 -2
View File
@@ -116,8 +116,7 @@ alias_config_cmd_delete_cb (const void *pointer, void *data,
if (ptr_alias)
alias_free (ptr_alias);
if (ptr_option_completion)
weechat_config_option_free (ptr_option_completion);
weechat_config_option_free (ptr_option_completion);
}
/*
+1 -2
View File
@@ -2284,8 +2284,7 @@ irc_server_free_data (struct t_irc_server *server)
/* free server data */
for (i = 0; i < IRC_SERVER_NUM_OPTIONS; i++)
{
if (server->options[i])
weechat_config_option_free (server->options[i]);
weechat_config_option_free (server->options[i]);
}
free (server->name);
free (server->addresses_eval);
+1 -2
View File
@@ -260,8 +260,7 @@ relay_command_relay (const void *pointer, void *data,
relay_config_file,
(unix_socket) ? relay_config_section_path : relay_config_section_port,
argv_eol[2]);
if (ptr_option)
weechat_config_option_free (ptr_option);
weechat_config_option_free (ptr_option);
weechat_printf (NULL,
_("%s: relay \"%s\" (%s: %s) removed"),
RELAY_PLUGIN_NAME,
+1 -2
View File
@@ -787,8 +787,7 @@ relay_remote_free (struct t_relay_remote *remote)
free (remote->name);
for (i = 0; i < RELAY_REMOTE_NUM_OPTIONS; i++)
{
if (remote->options[i])
weechat_config_option_free (remote->options[i]);
weechat_config_option_free (remote->options[i]);
}
free (remote->address);
free (remote->websocket_key);
+1 -2
View File
@@ -1230,8 +1230,7 @@ trigger_free (struct t_trigger *trigger)
free (trigger->name);
for (i = 0; i < TRIGGER_NUM_OPTIONS; i++)
{
if (trigger->options[i])
weechat_config_option_free (trigger->options[i]);
weechat_config_option_free (trigger->options[i]);
}
weechat_string_free_split (trigger->commands);
+2 -1
View File
@@ -1540,7 +1540,8 @@ TEST(CoreConfigFile, OptionFreeData)
TEST(CoreConfigFile, OptionFree)
{
/* TODO: write tests */
/* test free of NULL option */
config_file_option_free (NULL, 1);
}
/*