1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-29 22:36:38 +02:00

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

This commit is contained in:
Sébastien Helleu
2024-04-25 00:21:54 +02:00
parent 828ca37225
commit 529a22e342
14 changed files with 34 additions and 71 deletions
+1 -2
View File
@@ -605,8 +605,7 @@ alias_free (struct t_alias *alias)
alias_remove_from_list (alias);
/* free data */
if (alias->hook)
weechat_unhook (alias->hook);
weechat_unhook (alias->hook);
free (alias->name);
free (alias->command);
free (alias->completion);
+1 -2
View File
@@ -635,8 +635,7 @@ exec_free (struct t_exec_cmd *exec_cmd)
last_exec_cmd = exec_cmd->prev_cmd;
/* free data */
if (exec_cmd->hook)
weechat_unhook (exec_cmd->hook);
weechat_unhook (exec_cmd->hook);
free (exec_cmd->name);
free (exec_cmd->command);
free (exec_cmd->buffer_full_name);
+1 -2
View File
@@ -1545,8 +1545,7 @@ irc_channel_free (struct t_irc_server *server, struct t_irc_channel *channel)
weechat_hashtable_free (channel->join_msg_received);
free (channel->away_message);
free (channel->pv_remote_nick_color);
if (channel->hook_autorejoin)
weechat_unhook (channel->hook_autorejoin);
weechat_unhook (channel->hook_autorejoin);
if (channel->nicks_speaking[0])
weechat_list_free (channel->nicks_speaking[0]);
if (channel->nicks_speaking[1])
+2 -6
View File
@@ -1252,9 +1252,7 @@ irc_notify_print_log (struct t_irc_server *server)
void
irc_notify_hook_timer_ison ()
{
if (irc_notify_timer_ison)
weechat_unhook (irc_notify_timer_ison);
weechat_unhook (irc_notify_timer_ison);
irc_notify_timer_ison = weechat_hook_timer (
60 * 1000 * weechat_config_integer (irc_config_network_notify_check_ison),
0, 0, &irc_notify_timer_ison_cb, NULL, NULL);
@@ -1267,9 +1265,7 @@ irc_notify_hook_timer_ison ()
void
irc_notify_hook_timer_whois ()
{
if (irc_notify_timer_whois)
weechat_unhook (irc_notify_timer_whois);
weechat_unhook (irc_notify_timer_whois);
irc_notify_timer_whois = weechat_hook_timer (
60 * 1000 * weechat_config_integer (irc_config_network_notify_check_whois),
0, 0, &irc_notify_timer_whois_cb, NULL, NULL);
+1 -2
View File
@@ -1246,8 +1246,7 @@ IRC_PROTOCOL_CALLBACK(cap)
irc_server_sendf (ctxt->server, 0, NULL, str_msg_auth_upper);
free (str_msg_auth_upper);
}
if (ctxt->server->hook_timer_sasl)
weechat_unhook (ctxt->server->hook_timer_sasl);
weechat_unhook (ctxt->server->hook_timer_sasl);
timeout = IRC_SERVER_OPTION_INTEGER(
ctxt->server, IRC_SERVER_OPTION_SASL_TIMEOUT);
ctxt->server->hook_timer_sasl = weechat_hook_timer (
+6 -12
View File
@@ -2298,16 +2298,11 @@ irc_server_free_data (struct t_irc_server *server)
free (server->retry_array);
free (server->current_address);
free (server->current_ip);
if (server->hook_connect)
weechat_unhook (server->hook_connect);
if (server->hook_fd)
weechat_unhook (server->hook_fd);
if (server->hook_timer_connection)
weechat_unhook (server->hook_timer_connection);
if (server->hook_timer_sasl)
weechat_unhook (server->hook_timer_sasl);
if (server->hook_timer_anti_flood)
weechat_unhook (server->hook_timer_anti_flood);
weechat_unhook (server->hook_connect);
weechat_unhook (server->hook_fd);
weechat_unhook (server->hook_timer_connection);
weechat_unhook (server->hook_timer_sasl);
weechat_unhook (server->hook_timer_anti_flood);
irc_server_free_sasl_data (server);
free (server->unterminated_message);
if (server->nicks_array)
@@ -4396,8 +4391,7 @@ irc_server_login (struct t_irc_server *server)
(realname && realname[0]) ? realname : ((username2) ? username2 : "weechat"));
free (username2);
if (server->hook_timer_connection)
weechat_unhook (server->hook_timer_connection);
weechat_unhook (server->hook_timer_connection);
server->hook_timer_connection = weechat_hook_timer (
IRC_SERVER_OPTION_INTEGER (server, IRC_SERVER_OPTION_CONNECTION_TIMEOUT) * 1000,
0, 1,
+1 -3
View File
@@ -135,9 +135,7 @@ logger_config_color_lines_change (const void *pointer, void *data,
if (logger_config_loading)
return;
if (logger_hook_print)
weechat_unhook (logger_hook_print);
weechat_unhook (logger_hook_print);
logger_hook_print = weechat_hook_print (
NULL, NULL, NULL,
(weechat_config_boolean (logger_config_file_color_lines)) ? 0 : 1,
+3 -6
View File
@@ -241,12 +241,9 @@ relay_api_free (struct t_relay_client *client)
if (client->protocol_data)
{
if (RELAY_API_DATA(client, hook_signal_buffer))
weechat_unhook (RELAY_API_DATA(client, hook_signal_buffer));
if (RELAY_API_DATA(client, hook_hsignal_nicklist))
weechat_unhook (RELAY_API_DATA(client, hook_hsignal_nicklist));
if (RELAY_API_DATA(client, hook_signal_upgrade))
weechat_unhook (RELAY_API_DATA(client, hook_signal_upgrade));
weechat_unhook (RELAY_API_DATA(client, hook_signal_buffer));
weechat_unhook (RELAY_API_DATA(client, hook_hsignal_nicklist));
weechat_unhook (RELAY_API_DATA(client, hook_signal_upgrade));
free (client->protocol_data);
+4 -8
View File
@@ -2295,14 +2295,10 @@ relay_irc_free (struct t_relay_client *client)
{
free (RELAY_IRC_DATA(client, address));
free (RELAY_IRC_DATA(client, nick));
if (RELAY_IRC_DATA(client, hook_signal_irc_in2))
weechat_unhook (RELAY_IRC_DATA(client, hook_signal_irc_in2));
if (RELAY_IRC_DATA(client, hook_signal_irc_outtags))
weechat_unhook (RELAY_IRC_DATA(client, hook_signal_irc_outtags));
if (RELAY_IRC_DATA(client, hook_signal_irc_disc))
weechat_unhook (RELAY_IRC_DATA(client, hook_signal_irc_disc));
if (RELAY_IRC_DATA(client, hook_hsignal_irc_redir))
weechat_unhook (RELAY_IRC_DATA(client, hook_hsignal_irc_redir));
weechat_unhook (RELAY_IRC_DATA(client, hook_signal_irc_in2));
weechat_unhook (RELAY_IRC_DATA(client, hook_signal_irc_outtags));
weechat_unhook (RELAY_IRC_DATA(client, hook_signal_irc_disc));
weechat_unhook (RELAY_IRC_DATA(client, hook_hsignal_irc_redir));
free (client->protocol_data);
+3 -6
View File
@@ -1906,14 +1906,11 @@ relay_client_free (struct t_relay_client *client)
free (client->protocol_string);
free (client->protocol_args);
free (client->nonce);
if (client->hook_timer_handshake)
weechat_unhook (client->hook_timer_handshake);
weechat_unhook (client->hook_timer_handshake);
relay_websocket_deflate_free (client->ws_deflate);
relay_http_request_free (client->http_req);
if (client->hook_fd)
weechat_unhook (client->hook_fd);
if (client->hook_timer_send)
weechat_unhook (client->hook_timer_send);
weechat_unhook (client->hook_fd);
weechat_unhook (client->hook_timer_send);
free (client->partial_ws_frame);
free (client->partial_message);
if (client->protocol_data)
+3 -6
View File
@@ -792,12 +792,9 @@ relay_remote_free (struct t_relay_remote *remote)
}
free (remote->address);
free (remote->websocket_key);
if (remote->hook_url_handshake)
weechat_unhook (remote->hook_url_handshake);
if (remote->hook_connect)
weechat_unhook (remote->hook_connect);
if (remote->hook_fd)
weechat_unhook (remote->hook_fd);
weechat_unhook (remote->hook_url_handshake);
weechat_unhook (remote->hook_connect);
weechat_unhook (remote->hook_fd);
relay_websocket_deflate_free (remote->ws_deflate);
free (remote->partial_ws_frame);
+4 -8
View File
@@ -319,16 +319,12 @@ relay_weechat_free (struct t_relay_client *client)
{
if (RELAY_WEECHAT_DATA(client, buffers_sync))
weechat_hashtable_free (RELAY_WEECHAT_DATA(client, buffers_sync));
if (RELAY_WEECHAT_DATA(client, hook_signal_buffer))
weechat_unhook (RELAY_WEECHAT_DATA(client, hook_signal_buffer));
if (RELAY_WEECHAT_DATA(client, hook_hsignal_nicklist))
weechat_unhook (RELAY_WEECHAT_DATA(client, hook_hsignal_nicklist));
if (RELAY_WEECHAT_DATA(client, hook_signal_upgrade))
weechat_unhook (RELAY_WEECHAT_DATA(client, hook_signal_upgrade));
weechat_unhook (RELAY_WEECHAT_DATA(client, hook_signal_buffer));
weechat_unhook (RELAY_WEECHAT_DATA(client, hook_hsignal_nicklist));
weechat_unhook (RELAY_WEECHAT_DATA(client, hook_signal_upgrade));
if (RELAY_WEECHAT_DATA(client, buffers_nicklist))
weechat_hashtable_free (RELAY_WEECHAT_DATA(client, buffers_nicklist));
if (RELAY_WEECHAT_DATA(client, hook_timer_nicklist))
weechat_unhook (RELAY_WEECHAT_DATA(client, hook_timer_nicklist));
weechat_unhook (RELAY_WEECHAT_DATA(client, hook_timer_nicklist));
free (client->protocol_data);
+1 -2
View File
@@ -279,8 +279,7 @@ trigger_unhook (struct t_trigger *trigger)
{
for (i = 0; i < trigger->hooks_count; i++)
{
if (trigger->hooks[i])
weechat_unhook (trigger->hooks[i]);
weechat_unhook (trigger->hooks[i]);
}
free (trigger->hooks);
trigger->hooks = NULL;
+3 -6
View File
@@ -939,12 +939,9 @@ xfer_free (struct t_xfer *xfer)
free (xfer->remote_address);
free (xfer->remote_address_str);
free (xfer->remote_nick_color);
if (xfer->hook_fd)
weechat_unhook (xfer->hook_fd);
if (xfer->hook_timer)
weechat_unhook (xfer->hook_timer);
if (xfer->hook_connect)
weechat_unhook (xfer->hook_connect);
weechat_unhook (xfer->hook_fd);
weechat_unhook (xfer->hook_timer);
weechat_unhook (xfer->hook_connect);
free (xfer->unterminated_message);
free (xfer->local_filename);
free (xfer->temp_local_filename);