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

core: remove check of NULL pointers before calling hashtable_free() (issue #865)

This commit is contained in:
Sébastien Helleu
2024-04-25 19:05:34 +02:00
parent 0b2d9bcb9b
commit f11c7c1bf4
15 changed files with 23 additions and 46 deletions
+2 -4
View File
@@ -2485,10 +2485,8 @@ COMMAND_CALLBACK(eval)
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
}
if (pointers)
hashtable_free (pointers);
if (options)
hashtable_free (options);
hashtable_free (pointers);
hashtable_free (options);
}
return WEECHAT_RC_OK;
+1 -2
View File
@@ -1317,8 +1317,7 @@ completion_list_add_plugins_installed_cb (const void *pointer, void *data,
hashtable_set (options, "directory", "data");
plugin_path = string_eval_path_home (CONFIG_STRING(config_plugin_path),
NULL, NULL, options);
if (options)
hashtable_free (options);
hashtable_free (options);
if (plugin_path)
{
dir_exec_on_files (plugin_path, 1, 0,
+1 -2
View File
@@ -2778,8 +2778,7 @@ eval_expression (const char *expr, struct t_hashtable *pointers,
if (ptr_buffer_added)
hashtable_remove (pointers, "buffer");
}
if (user_vars)
hashtable_free (user_vars);
hashtable_free (user_vars);
if (regex && regex_allocated)
{
regfree (regex);
+2 -4
View File
@@ -1404,12 +1404,10 @@ hdata_free (struct t_hdata *hdata)
if (!hdata)
return;
if (hdata->hash_var)
hashtable_free (hdata->hash_var);
hashtable_free (hdata->hash_var);
free (hdata->var_prev);
free (hdata->var_next);
if (hdata->hash_list)
hashtable_free (hdata->hash_list);
hashtable_free (hdata->hash_list);
free (hdata->name);
free (hdata);
+1 -2
View File
@@ -234,8 +234,7 @@ network_load_user_ca_files (int force_display)
end:
if (paths)
string_free_split (paths);
if (options)
hashtable_free (options);
hashtable_free (options);
network_num_certs_user = num_loaded;
+1 -2
View File
@@ -244,8 +244,7 @@ secure_buffer_open ()
secure_buffer_display_values = 0;
if (properties)
hashtable_free (properties);
hashtable_free (properties);
}
if (!secure_buffer)
+1 -2
View File
@@ -205,8 +205,7 @@ hook_line_exec (struct t_gui_line *line)
hook_exec_end ();
if (hashtable)
hashtable_free (hashtable);
hashtable_free (hashtable);
}
/*
+1 -2
View File
@@ -1335,8 +1335,7 @@ gui_color_buffer_open ()
if (gui_color_buffer && !gui_color_buffer->short_name)
gui_color_buffer->short_name = strdup (GUI_COLOR_BUFFER_NAME);
if (properties)
hashtable_free (properties);
hashtable_free (properties);
}
if (!gui_color_buffer)
+2 -4
View File
@@ -333,10 +333,8 @@ gui_bar_item_custom_callback (const void *pointer,
pointers, NULL, NULL);
end:
if (pointers)
hashtable_free (pointers);
if (options)
hashtable_free (options);
hashtable_free (pointers);
hashtable_free (options);
return result;
}
+3 -6
View File
@@ -419,12 +419,9 @@ gui_bar_check_conditions (struct t_gui_bar *bar,
rc = eval_is_true (result);
free (result);
if (pointers)
hashtable_free (pointers);
if (extra_vars)
hashtable_free (extra_vars);
if (options)
hashtable_free (options);
hashtable_free (pointers);
hashtable_free (extra_vars);
hashtable_free (options);
if (!rc)
return 0;
}
+2 -4
View File
@@ -1156,8 +1156,7 @@ gui_buffer_new_user (const char *name, enum t_gui_buffer_type buffer_type)
&gui_buffer_user_input_cb, NULL, NULL,
&gui_buffer_user_close_cb, NULL, NULL);
if (properties)
hashtable_free (properties);
hashtable_free (properties);
return new_buffer;
}
@@ -3712,8 +3711,7 @@ gui_buffer_close (struct t_gui_buffer *buffer)
gui_completion_free (buffer->completion);
gui_nicklist_remove_all (buffer);
gui_nicklist_remove_group (buffer, buffer->nicklist_root);
if (buffer->hotlist_max_level_nicks)
hashtable_free (buffer->hotlist_max_level_nicks);
hashtable_free (buffer->hotlist_max_level_nicks);
gui_key_free_all (-1, &buffer->keys, &buffer->last_key,
&buffer->keys_count, 0);
gui_buffer_local_var_remove_all (buffer);
+1 -2
View File
@@ -421,8 +421,7 @@ gui_chat_get_time_string (time_t date, int date_usec, int highlight)
if (extra_vars)
hashtable_set (extra_vars, "highlight", (highlight) ? "1" : "0");
text_with_color = eval_expression (text_time, NULL, extra_vars, NULL);
if (extra_vars)
hashtable_free (extra_vars);
hashtable_free (extra_vars);
if (text_with_color)
{
if (strcmp (text_time, text_with_color) != 0)
+2 -4
View File
@@ -2013,10 +2013,8 @@ gui_color_palette_remove (int number)
void
gui_color_palette_free_structs ()
{
if (gui_color_hash_palette_color)
hashtable_free (gui_color_hash_palette_color);
if (gui_color_hash_palette_alias)
hashtable_free (gui_color_hash_palette_alias);
hashtable_free (gui_color_hash_palette_color);
hashtable_free (gui_color_hash_palette_alias);
if (gui_color_list_with_alias)
weelist_free (gui_color_list_with_alias);
}
+1 -2
View File
@@ -1428,8 +1428,7 @@ gui_completion_get_default_template (struct t_gui_completion *completion)
NULL, NULL);
hashtable_set (pointers, "buffer", completion->buffer);
value = eval_expression (ptr_default_template, pointers, NULL, NULL);
if (pointers)
hashtable_free (pointers);
hashtable_free (pointers);
return (value) ? value : strdup ("");
}
+2 -4
View File
@@ -2250,10 +2250,8 @@ end:
gui_focus_free_info (focus_info1);
if (focus_info2)
gui_focus_free_info (focus_info2);
if (hashtable_focus[0])
hashtable_free (hashtable_focus[0]);
if (hashtable_focus[1])
hashtable_free (hashtable_focus[1]);
hashtable_free (hashtable_focus[0]);
hashtable_free (hashtable_focus[1]);
return rc;
}