mirror of
https://github.com/weechat/weechat.git
synced 2026-07-06 01:33:12 +02:00
core: remove check of NULL pointers before calling free() (issue #865)
This commit is contained in:
@@ -687,10 +687,7 @@ arraylist_free (struct t_arraylist *arraylist)
|
||||
arraylist->data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (arraylist->data)
|
||||
free (arraylist->data);
|
||||
|
||||
free (arraylist->data);
|
||||
free (arraylist);
|
||||
}
|
||||
|
||||
|
||||
+24
-48
@@ -450,8 +450,7 @@ COMMAND_CALLBACK(bar)
|
||||
name = strdup (ptr_bar->name);
|
||||
gui_bar_free (ptr_bar);
|
||||
gui_chat_printf (NULL, _("Bar \"%s\" deleted"), name);
|
||||
if (name)
|
||||
free (name);
|
||||
free (name);
|
||||
gui_bar_create_default_input ();
|
||||
}
|
||||
ptr_bar = ptr_next_bar;
|
||||
@@ -1302,8 +1301,7 @@ COMMAND_CALLBACK(buffer)
|
||||
gui_buffer_local_var_add (buffer,
|
||||
argv[2],
|
||||
(value) ? value : argv_eol[3]);
|
||||
if (value)
|
||||
free (value);
|
||||
free (value);
|
||||
}
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
@@ -1332,8 +1330,7 @@ COMMAND_CALLBACK(buffer)
|
||||
{
|
||||
value = string_remove_quotes (argv_eol[3], "'\"");
|
||||
gui_buffer_set (buffer, argv[2], (value) ? value : argv_eol[3]);
|
||||
if (value)
|
||||
free (value);
|
||||
free (value);
|
||||
}
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
@@ -1359,8 +1356,7 @@ COMMAND_CALLBACK(buffer)
|
||||
rc = config_weechat_buffer_set (buffer,
|
||||
argv[2],
|
||||
(value) ? value : argv_eol[3]);
|
||||
if (value)
|
||||
free (value);
|
||||
free (value);
|
||||
}
|
||||
if (!rc)
|
||||
{
|
||||
@@ -2067,8 +2063,7 @@ COMMAND_CALLBACK(debug)
|
||||
gui_chat_printf (NULL,
|
||||
_("Debug enabled for callbacks (threshold: %s)"),
|
||||
(str_threshold) ? str_threshold : "?");
|
||||
if (str_threshold)
|
||||
free (str_threshold);
|
||||
free (str_threshold);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2301,8 +2296,7 @@ command_eval_print_debug (const char *debug)
|
||||
|
||||
gui_chat_printf (NULL, "%s", (string) ? string : debug);
|
||||
|
||||
if (string)
|
||||
free (string);
|
||||
free (string);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2848,8 +2842,7 @@ COMMAND_CALLBACK(filter)
|
||||
NULL, 0, GUI_FILTER_TAG_NO_FILTER,
|
||||
_("Filter \"%s\" deleted"),
|
||||
name);
|
||||
if (name)
|
||||
free (name);
|
||||
free (name);
|
||||
}
|
||||
ptr_filter = ptr_next_filter;
|
||||
}
|
||||
@@ -3150,8 +3143,7 @@ COMMAND_CALLBACK(help)
|
||||
(string) ? string : ptr_string);
|
||||
first_line_displayed = 1;
|
||||
}
|
||||
if (string)
|
||||
free (string);
|
||||
free (string);
|
||||
|
||||
if (pos_double_pipe)
|
||||
{
|
||||
@@ -3924,8 +3916,7 @@ COMMAND_CALLBACK(item)
|
||||
gui_chat_printf (NULL,
|
||||
_("Custom bar item \"%s\" deleted"),
|
||||
name);
|
||||
if (name)
|
||||
free (name);
|
||||
free (name);
|
||||
}
|
||||
ptr_bar_item_custom = ptr_next_bar_item_custom;
|
||||
}
|
||||
@@ -4249,8 +4240,7 @@ COMMAND_CALLBACK(key)
|
||||
argv[2],
|
||||
(value) ? value : argv_eol[3],
|
||||
1); /* check_key */
|
||||
if (value)
|
||||
free (value);
|
||||
free (value);
|
||||
gui_key_verbose = 0;
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
@@ -4297,8 +4287,7 @@ COMMAND_CALLBACK(key)
|
||||
argv[3],
|
||||
(value) ? value : argv_eol[4],
|
||||
1); /* check_key */
|
||||
if (value)
|
||||
free (value);
|
||||
free (value);
|
||||
gui_key_verbose = 0;
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
@@ -4458,8 +4447,7 @@ COMMAND_CALLBACK(key)
|
||||
GUI_COLOR(GUI_COLOR_CHAT),
|
||||
key_name,
|
||||
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
|
||||
if (key_name)
|
||||
free (key_name);
|
||||
free (key_name);
|
||||
}
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
@@ -4682,8 +4670,7 @@ COMMAND_CALLBACK(layout)
|
||||
_("Layout \"%s\" deleted (current layout: %s)"),
|
||||
name,
|
||||
(gui_layout_current) ? gui_layout_current->name : "-");
|
||||
if (name)
|
||||
free (name);
|
||||
free (name);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -5161,8 +5148,7 @@ COMMAND_CALLBACK(plugin)
|
||||
}
|
||||
full_name = dir_search_full_lib_name (argv[2], "plugins");
|
||||
plugin_load (full_name, 1, plugin_argc, plugin_argv);
|
||||
if (full_name)
|
||||
free (full_name);
|
||||
free (full_name);
|
||||
if (plugin_argv)
|
||||
string_free_split (plugin_argv);
|
||||
return WEECHAT_RC_OK;
|
||||
@@ -5587,8 +5573,7 @@ COMMAND_CALLBACK(proxy)
|
||||
name = strdup (ptr_proxy->name);
|
||||
proxy_free (ptr_proxy);
|
||||
gui_chat_printf (NULL, _("Proxy \"%s\" deleted"), name);
|
||||
if (name)
|
||||
free (name);
|
||||
free (name);
|
||||
}
|
||||
ptr_proxy = ptr_next_proxy;
|
||||
}
|
||||
@@ -5841,8 +5826,7 @@ command_repeat_exec (struct t_command_repeat *command_repeat)
|
||||
/* it was the last execution, free up memory */
|
||||
free (command_repeat->buffer_name);
|
||||
free (command_repeat->command);
|
||||
if (command_repeat->commands_allowed)
|
||||
free (command_repeat->commands_allowed);
|
||||
free (command_repeat->commands_allowed);
|
||||
free (command_repeat);
|
||||
}
|
||||
}
|
||||
@@ -6198,8 +6182,7 @@ COMMAND_CALLBACK(secure)
|
||||
{
|
||||
gui_chat_printf (NULL,
|
||||
_("Encrypted data has been successfully decrypted"));
|
||||
if (secure_passphrase)
|
||||
free (secure_passphrase);
|
||||
free (secure_passphrase);
|
||||
secure_passphrase = strdup (argv_eol[2]);
|
||||
}
|
||||
return WEECHAT_RC_OK;
|
||||
@@ -6415,12 +6398,9 @@ command_set_display_option (struct t_config_option *option,
|
||||
(default_value) ? GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS) : "",
|
||||
(default_value) ? ")" : "");
|
||||
|
||||
if (value)
|
||||
free (value);
|
||||
if (inherited_value)
|
||||
free (inherited_value);
|
||||
if (default_value)
|
||||
free (default_value);
|
||||
free (value);
|
||||
free (inherited_value);
|
||||
free (default_value);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -6687,8 +6667,7 @@ COMMAND_CALLBACK(set)
|
||||
strerror (errno));
|
||||
}
|
||||
}
|
||||
if (value)
|
||||
free (value);
|
||||
free (value);
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -6749,8 +6728,7 @@ COMMAND_CALLBACK(set)
|
||||
value = (string_strcmp (argv_eol[2], WEECHAT_CONFIG_OPTION_NULL) == 0) ?
|
||||
NULL : string_remove_quotes (argv_eol[2], "'\"");
|
||||
rc = config_file_option_set_with_string (argv[1], value);
|
||||
if (value)
|
||||
free (value);
|
||||
free (value);
|
||||
switch (rc)
|
||||
{
|
||||
case WEECHAT_CONFIG_OPTION_SET_ERROR:
|
||||
@@ -6905,8 +6883,7 @@ COMMAND_CALLBACK(toggle)
|
||||
COMMAND_ERROR;
|
||||
if (string_strcmp (argv[2], WEECHAT_CONFIG_OPTION_NULL) == 0)
|
||||
{
|
||||
if (sargv[0])
|
||||
free (sargv[0]);
|
||||
free (sargv[0]);
|
||||
sargv[0] = NULL;
|
||||
}
|
||||
}
|
||||
@@ -7298,8 +7275,7 @@ COMMAND_CALLBACK(upgrade)
|
||||
_("%sUnable to save WeeChat session "
|
||||
"(files *.upgrade)"),
|
||||
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
|
||||
if (ptr_binary)
|
||||
free (ptr_binary);
|
||||
free (ptr_binary);
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -889,17 +889,11 @@ completion_list_add_filename_cb (const void *pointer, void *data,
|
||||
closedir (dp);
|
||||
|
||||
end:
|
||||
if (real_prefix)
|
||||
free (real_prefix);
|
||||
if (prefix)
|
||||
free (prefix);
|
||||
if (path_dir)
|
||||
free (path_dir);
|
||||
if (path_base)
|
||||
free (path_base);
|
||||
if (dir_name)
|
||||
free (dir_name);
|
||||
|
||||
free (real_prefix);
|
||||
free (prefix);
|
||||
free (path_dir);
|
||||
free (path_base);
|
||||
free (dir_name);
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -1649,11 +1643,8 @@ completion_list_add_config_option_values_cb (const void *pointer, void *data,
|
||||
}
|
||||
}
|
||||
|
||||
if (file)
|
||||
free (file);
|
||||
if (section)
|
||||
free (section);
|
||||
|
||||
free (file);
|
||||
free (section);
|
||||
free (option_full_name);
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
+37
-74
@@ -986,10 +986,8 @@ error:
|
||||
}
|
||||
|
||||
end:
|
||||
if (option_name)
|
||||
free (option_name);
|
||||
if (parent_name)
|
||||
free (parent_name);
|
||||
free (option_name);
|
||||
free (parent_name);
|
||||
return new_option;
|
||||
}
|
||||
|
||||
@@ -1170,10 +1168,8 @@ config_file_search_with_string (const char *option_name,
|
||||
}
|
||||
}
|
||||
|
||||
if (file_name)
|
||||
free (file_name);
|
||||
if (section_name)
|
||||
free (section_name);
|
||||
free (file_name);
|
||||
free (section_name);
|
||||
|
||||
if (config_file)
|
||||
*config_file = ptr_config;
|
||||
@@ -1839,8 +1835,7 @@ config_file_option_toggle (struct t_config_option *option,
|
||||
rc = config_file_option_set (option, ptr_new_value, run_callback);
|
||||
|
||||
end:
|
||||
if (current_value)
|
||||
free (current_value);
|
||||
free (current_value);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -2320,8 +2315,7 @@ config_file_option_rename (struct t_config_option *option,
|
||||
}
|
||||
|
||||
/* rename option */
|
||||
if (option->name)
|
||||
free (option->name);
|
||||
free (option->name);
|
||||
option->name = str_new_name;
|
||||
|
||||
/* re-insert option in section */
|
||||
@@ -2354,10 +2348,8 @@ config_file_option_rename (struct t_config_option *option,
|
||||
}
|
||||
}
|
||||
|
||||
if (full_old_name)
|
||||
free (full_old_name);
|
||||
if (full_new_name)
|
||||
free (full_new_name);
|
||||
free (full_old_name);
|
||||
free (full_new_name);
|
||||
|
||||
config_file_hook_config_exec (option);
|
||||
}
|
||||
@@ -3576,8 +3568,7 @@ config_file_update_data_read (struct t_config_file *config_file,
|
||||
ptr_section = hashtable_get (hashtable, "section");
|
||||
if (ptr_section && ptr_section[0])
|
||||
{
|
||||
if (*ret_section)
|
||||
free (*ret_section);
|
||||
free (*ret_section);
|
||||
*ret_section = strdup (ptr_section);
|
||||
}
|
||||
}
|
||||
@@ -3591,8 +3582,7 @@ config_file_update_data_read (struct t_config_file *config_file,
|
||||
ptr_option = hashtable_get (hashtable, "option");
|
||||
if (ptr_option)
|
||||
{
|
||||
if (*ret_option)
|
||||
free (*ret_option);
|
||||
free (*ret_option);
|
||||
*ret_option = strdup (ptr_option);
|
||||
}
|
||||
}
|
||||
@@ -3602,8 +3592,7 @@ config_file_update_data_read (struct t_config_file *config_file,
|
||||
ptr_value = hashtable_get (hashtable, "value");
|
||||
if (!value_null && hashtable_has_key (hashtable, "value_null"))
|
||||
ptr_value = NULL;
|
||||
if (*ret_value)
|
||||
free (*ret_value);
|
||||
free (*ret_value);
|
||||
*ret_value = (ptr_value) ? strdup (ptr_value) : NULL;
|
||||
}
|
||||
}
|
||||
@@ -3823,10 +3812,8 @@ config_file_read_internal (struct t_config_file *config_file, int reload)
|
||||
filename, line_number,
|
||||
line);
|
||||
config_file_backup (filename);
|
||||
if (option)
|
||||
free (option);
|
||||
if (value)
|
||||
free (value);
|
||||
free (option);
|
||||
free (value);
|
||||
goto end_file;
|
||||
}
|
||||
else
|
||||
@@ -3844,10 +3831,8 @@ config_file_read_internal (struct t_config_file *config_file, int reload)
|
||||
config_file->version_read,
|
||||
config_file->version);
|
||||
config_file_backup (filename);
|
||||
if (option)
|
||||
free (option);
|
||||
if (value)
|
||||
free (value);
|
||||
free (option);
|
||||
free (value);
|
||||
goto end_file;
|
||||
}
|
||||
}
|
||||
@@ -3936,10 +3921,8 @@ config_file_read_internal (struct t_config_file *config_file, int reload)
|
||||
}
|
||||
|
||||
end_line:
|
||||
if (option)
|
||||
free (option);
|
||||
if (value)
|
||||
free (value);
|
||||
free (option);
|
||||
free (value);
|
||||
}
|
||||
|
||||
end_file:
|
||||
@@ -4028,24 +4011,16 @@ config_file_reload (struct t_config_file *config_file)
|
||||
void
|
||||
config_file_option_free_data (struct t_config_option *option)
|
||||
{
|
||||
if (option->name)
|
||||
free (option->name);
|
||||
if (option->parent_name)
|
||||
free (option->parent_name);
|
||||
if (option->description)
|
||||
free (option->description);
|
||||
free (option->name);
|
||||
free (option->parent_name);
|
||||
free (option->description);
|
||||
if (option->string_values)
|
||||
string_free_split (option->string_values);
|
||||
if (option->default_value)
|
||||
free (option->default_value);
|
||||
if (option->value)
|
||||
free (option->value);
|
||||
if (option->callback_check_value_data)
|
||||
free (option->callback_check_value_data);
|
||||
if (option->callback_change_data)
|
||||
free (option->callback_change_data);
|
||||
if (option->callback_delete_data)
|
||||
free (option->callback_delete_data);
|
||||
free (option->default_value);
|
||||
free (option->value);
|
||||
free (option->callback_check_value_data);
|
||||
free (option->callback_change_data);
|
||||
free (option->callback_delete_data);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -4129,18 +4104,12 @@ config_file_section_free (struct t_config_section *section)
|
||||
|
||||
/* free data */
|
||||
config_file_section_free_options (section);
|
||||
if (section->name)
|
||||
free (section->name);
|
||||
if (section->callback_read_data)
|
||||
free (section->callback_read_data);
|
||||
if (section->callback_write_data)
|
||||
free (section->callback_write_data);
|
||||
if (section->callback_write_default_data)
|
||||
free (section->callback_write_default_data);
|
||||
if (section->callback_create_option_data)
|
||||
free (section->callback_create_option_data);
|
||||
if (section->callback_delete_option_data)
|
||||
free (section->callback_delete_option_data);
|
||||
free (section->name);
|
||||
free (section->callback_read_data);
|
||||
free (section->callback_write_data);
|
||||
free (section->callback_write_default_data);
|
||||
free (section->callback_create_option_data);
|
||||
free (section->callback_delete_option_data);
|
||||
|
||||
/* remove section from list */
|
||||
if (ptr_config->last_section == section)
|
||||
@@ -4178,10 +4147,8 @@ config_file_free (struct t_config_file *config_file)
|
||||
{
|
||||
config_file_section_free (config_file->sections);
|
||||
}
|
||||
if (config_file->name)
|
||||
free (config_file->name);
|
||||
if (config_file->filename)
|
||||
free (config_file->filename);
|
||||
free (config_file->name);
|
||||
free (config_file->filename);
|
||||
|
||||
/* remove configuration file from list */
|
||||
if (last_config_file == config_file)
|
||||
@@ -4198,10 +4165,8 @@ config_file_free (struct t_config_file *config_file)
|
||||
(config_file->next_config)->prev_config = config_file->prev_config;
|
||||
|
||||
/* free data */
|
||||
if (config_file->callback_update_data)
|
||||
free (config_file->callback_update_data);
|
||||
if (config_file->callback_reload_data)
|
||||
free (config_file->callback_reload_data);
|
||||
free (config_file->callback_update_data);
|
||||
free (config_file->callback_reload_data);
|
||||
|
||||
free (config_file);
|
||||
|
||||
@@ -4429,12 +4394,10 @@ config_file_add_option_to_infolist (struct t_infolist *infolist,
|
||||
(const char **)option->string_values, "|", 0, -1);
|
||||
if (!infolist_new_var_string (ptr_item, "string_values", string_values))
|
||||
{
|
||||
if (string_values)
|
||||
free (string_values);
|
||||
free (string_values);
|
||||
goto error;
|
||||
}
|
||||
if (string_values)
|
||||
free (string_values);
|
||||
free (string_values);
|
||||
if (!infolist_new_var_integer (ptr_item, "min", option->min))
|
||||
goto error;
|
||||
if (!infolist_new_var_integer (ptr_item, "max", option->max))
|
||||
|
||||
+7
-14
@@ -535,18 +535,14 @@ config_set_word_chars (const char *str_word_chars,
|
||||
item = string_strndup (ptr_item, pos - ptr_item);
|
||||
item2 = string_convert_escaped_chars (item);
|
||||
(*word_chars)[i].char1 = utf8_char_int (item2);
|
||||
if (item)
|
||||
free (item);
|
||||
if (item2)
|
||||
free (item2);
|
||||
free (item);
|
||||
free (item2);
|
||||
/* char2 */
|
||||
item = strdup (pos + 1);
|
||||
item2 = string_convert_escaped_chars (item);
|
||||
(*word_chars)[i].char2 = utf8_char_int (item2);
|
||||
if (item)
|
||||
free (item);
|
||||
if (item2)
|
||||
free (item2);
|
||||
free (item);
|
||||
free (item2);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -557,8 +553,7 @@ config_set_word_chars (const char *str_word_chars,
|
||||
item = string_convert_escaped_chars (ptr_item);
|
||||
(*word_chars)[i].char1 = utf8_char_int (item);
|
||||
(*word_chars)[i].char2 = (*word_chars)[i].char1;
|
||||
if (item)
|
||||
free (item);
|
||||
free (item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -723,8 +718,7 @@ config_change_buffer_time_same (const void *pointer, void *data,
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
if (config_buffer_time_same_evaluated)
|
||||
free (config_buffer_time_same_evaluated);
|
||||
free (config_buffer_time_same_evaluated);
|
||||
config_buffer_time_same_evaluated = eval_expression (
|
||||
CONFIG_STRING(config_look_buffer_time_same), NULL, NULL, NULL);
|
||||
|
||||
@@ -1139,8 +1133,7 @@ config_change_item_time_format (const void *pointer, void *data,
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
if (config_item_time_evaluated)
|
||||
free (config_item_time_evaluated);
|
||||
free (config_item_time_evaluated);
|
||||
config_item_time_evaluated = eval_expression (
|
||||
CONFIG_STRING(config_look_item_time_format), NULL, NULL, NULL);
|
||||
|
||||
|
||||
@@ -610,10 +610,8 @@ weecrypto_totp_generate (const char *secret_base32, time_t totp_time,
|
||||
return result;
|
||||
|
||||
error:
|
||||
if (secret)
|
||||
free (secret);
|
||||
if (result)
|
||||
free (result);
|
||||
free (secret);
|
||||
free (result);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -676,7 +674,6 @@ weecrypto_totp_validate (const char *secret_base32, time_t totp_time,
|
||||
return otp_ok;
|
||||
|
||||
error:
|
||||
if (secret)
|
||||
free (secret);
|
||||
free (secret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -808,8 +808,7 @@ debug_display_time_elapsed (struct timeval *time1, struct timeval *time2,
|
||||
(str_diff) ? str_diff : "?");
|
||||
}
|
||||
|
||||
if (str_diff)
|
||||
free (str_diff);
|
||||
free (str_diff);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+14
-29
@@ -166,18 +166,12 @@ dir_mkdir_home (const char *directory, int mode)
|
||||
rc = 1;
|
||||
|
||||
end:
|
||||
if (dir)
|
||||
free (dir);
|
||||
if (dir1)
|
||||
free (dir1);
|
||||
if (dir2)
|
||||
free (dir2);
|
||||
if (dir3)
|
||||
free (dir3);
|
||||
if (dir4)
|
||||
free (dir4);
|
||||
if (dir5)
|
||||
free (dir5);
|
||||
free (dir);
|
||||
free (dir1);
|
||||
free (dir2);
|
||||
free (dir3);
|
||||
free (dir4);
|
||||
free (dir5);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -424,10 +418,8 @@ memory_error:
|
||||
string_fprintf (stderr, _("Error: not enough memory\n"));
|
||||
|
||||
end:
|
||||
if (temp_dir)
|
||||
free (temp_dir);
|
||||
if (temp_home_template)
|
||||
free (temp_home_template);
|
||||
free (temp_dir);
|
||||
free (temp_home_template);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -1032,8 +1024,7 @@ dir_file_get_content (const char *filename)
|
||||
return buffer;
|
||||
|
||||
error:
|
||||
if (buffer)
|
||||
free (buffer);
|
||||
free (buffer);
|
||||
if (f)
|
||||
fclose (f);
|
||||
return NULL;
|
||||
@@ -1086,8 +1077,7 @@ dir_file_copy (const char *from, const char *to)
|
||||
rc = 1;
|
||||
|
||||
end:
|
||||
if (buffer)
|
||||
free (buffer);
|
||||
free (buffer);
|
||||
if (src)
|
||||
fclose (src);
|
||||
if (dst)
|
||||
@@ -1192,15 +1182,12 @@ error:
|
||||
unlink (to);
|
||||
|
||||
end:
|
||||
if (buffer_in)
|
||||
free (buffer_in);
|
||||
if (buffer_out)
|
||||
free (buffer_out);
|
||||
free (buffer_in);
|
||||
free (buffer_out);
|
||||
if (source)
|
||||
fclose (source);
|
||||
if (dest)
|
||||
fclose (dest);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -1370,10 +1357,8 @@ end:
|
||||
ZSTD_freeCStream (cstream);
|
||||
#endif
|
||||
|
||||
if (buffer_in)
|
||||
free (buffer_in);
|
||||
if (buffer_out)
|
||||
free (buffer_out);
|
||||
free (buffer_in);
|
||||
free (buffer_out);
|
||||
if (source)
|
||||
fclose (source);
|
||||
if (dest)
|
||||
|
||||
+9
-25
@@ -67,12 +67,8 @@ char *
|
||||
doc_gen_escape_table (const char *message)
|
||||
{
|
||||
index_string_escaped = (index_string_escaped + 1) % 32;
|
||||
|
||||
if (string_escaped[index_string_escaped])
|
||||
free (string_escaped[index_string_escaped]);
|
||||
|
||||
free (string_escaped[index_string_escaped]);
|
||||
string_escaped[index_string_escaped] = string_replace (message, "|", "\\|");
|
||||
|
||||
return string_escaped[index_string_escaped];
|
||||
}
|
||||
|
||||
@@ -89,15 +85,10 @@ doc_gen_escape_anchor_link (const char *message)
|
||||
return NULL;
|
||||
|
||||
index_string_escaped = (index_string_escaped + 1) % 32;
|
||||
|
||||
if (string_escaped[index_string_escaped])
|
||||
free (string_escaped[index_string_escaped]);
|
||||
|
||||
free (string_escaped[index_string_escaped]);
|
||||
string_escaped[index_string_escaped] = string_replace_regex (
|
||||
message, ®ex, "-", '$', NULL, NULL);
|
||||
|
||||
regfree (®ex);
|
||||
|
||||
return string_escaped[index_string_escaped];
|
||||
}
|
||||
|
||||
@@ -567,8 +558,7 @@ doc_gen_user_options (const char *path, const char *lang)
|
||||
if (ptr_option->type == CONFIG_OPTION_TYPE_STRING)
|
||||
{
|
||||
tmp = string_replace (default_value, "\"", "\\\"");
|
||||
if (default_value)
|
||||
free (default_value);
|
||||
free (default_value);
|
||||
default_value = tmp;
|
||||
}
|
||||
string_fprintf (
|
||||
@@ -578,12 +568,9 @@ doc_gen_user_options (const char *path, const char *lang)
|
||||
(ptr_option->type == CONFIG_OPTION_TYPE_STRING) ? "\"" : "",
|
||||
default_value,
|
||||
(ptr_option->type == CONFIG_OPTION_TYPE_STRING) ? "\"" : "");
|
||||
if (desc_escaped)
|
||||
free (desc_escaped);
|
||||
if (values)
|
||||
free (values);
|
||||
if (default_value)
|
||||
free (default_value);
|
||||
free (desc_escaped);
|
||||
free (values);
|
||||
free (default_value);
|
||||
}
|
||||
|
||||
if (old_config)
|
||||
@@ -1386,8 +1373,7 @@ doc_gen_api_url_options (const char *path, const char *lang)
|
||||
"| %s | %s |",
|
||||
ESCAPE_TABLE(name),
|
||||
ESCAPE_TABLE(url_type_string[url_options[i].type]));
|
||||
if (name)
|
||||
free (name);
|
||||
free (name);
|
||||
if (url_options[i].constants)
|
||||
{
|
||||
for (j = 0; url_options[i].constants[j].name; j++)
|
||||
@@ -1396,8 +1382,7 @@ doc_gen_api_url_options (const char *path, const char *lang)
|
||||
string_fprintf (file, ",");
|
||||
constant = string_tolower (url_options[i].constants[j].name);
|
||||
string_fprintf (file, " %s", constant);
|
||||
if (constant)
|
||||
free (constant);
|
||||
free (constant);
|
||||
}
|
||||
}
|
||||
string_fprintf (file, "\n");
|
||||
@@ -1787,8 +1772,7 @@ doc_generate (const char *path)
|
||||
end:
|
||||
for (i = 0; i < 32; i++)
|
||||
{
|
||||
if (string_escaped[i])
|
||||
free (string_escaped[i]);
|
||||
free (string_escaped[i]);
|
||||
}
|
||||
return rc_doc_gen;
|
||||
}
|
||||
|
||||
+29
-58
@@ -280,8 +280,7 @@ eval_string_eval_cond (const char *text, struct t_eval_context *eval_context)
|
||||
|
||||
tmp = eval_expression_condition (text, eval_context);
|
||||
rc = eval_is_true (tmp);
|
||||
if (tmp)
|
||||
free (tmp);
|
||||
free (tmp);
|
||||
return strdup ((rc) ? EVAL_STR_TRUE : EVAL_STR_FALSE);
|
||||
}
|
||||
|
||||
@@ -577,8 +576,7 @@ eval_string_split (const char *text)
|
||||
flags |= WEECHAT_STRING_SPLIT_KEEP_EOL;
|
||||
else if (strncmp (list_flags[i], "strip_items=", 12) == 0)
|
||||
{
|
||||
if (strip_items)
|
||||
free (strip_items);
|
||||
free (strip_items);
|
||||
strip_items = strdup (list_flags[i] + 12);
|
||||
}
|
||||
else if (strncmp (list_flags[i], "max_items=", 10) == 0)
|
||||
@@ -625,16 +623,12 @@ eval_string_split (const char *text)
|
||||
value = strdup (items[number]);
|
||||
|
||||
end:
|
||||
if (str_number)
|
||||
free (str_number);
|
||||
if (separators)
|
||||
free (separators);
|
||||
if (str_flags)
|
||||
free (str_flags);
|
||||
free (str_number);
|
||||
free (separators);
|
||||
free (str_flags);
|
||||
if (list_flags)
|
||||
string_free_split (list_flags);
|
||||
if (strip_items)
|
||||
free (strip_items);
|
||||
free (strip_items);
|
||||
if (items)
|
||||
string_free_split (items);
|
||||
return (value) ? value : strdup ("");
|
||||
@@ -731,8 +725,7 @@ eval_string_split_shell (const char *text)
|
||||
value = strdup (items[number]);
|
||||
|
||||
end:
|
||||
if (str_number)
|
||||
free (str_number);
|
||||
free (str_number);
|
||||
if (items)
|
||||
string_free_split (items);
|
||||
return (value) ? value : strdup ("");
|
||||
@@ -838,10 +831,8 @@ eval_string_modifier (const char *text)
|
||||
ptr_string - 1 - ptr_arguments);
|
||||
value = hook_modifier_exec (NULL, modifier_name, modifier_data,
|
||||
ptr_string);
|
||||
if (modifier_name)
|
||||
free (modifier_name);
|
||||
if (modifier_data)
|
||||
free (modifier_data);
|
||||
free (modifier_name);
|
||||
free (modifier_data);
|
||||
|
||||
return (value) ? value : strdup ("");
|
||||
}
|
||||
@@ -918,10 +909,8 @@ eval_string_base_encode (const char *text)
|
||||
|
||||
end:
|
||||
value = strdup ((result) ? result : "");
|
||||
if (base)
|
||||
free (base);
|
||||
if (result)
|
||||
free (result);
|
||||
free (base);
|
||||
free (result);
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -961,10 +950,8 @@ eval_string_base_decode (const char *text)
|
||||
|
||||
end:
|
||||
value = strdup ((result) ? result : "");
|
||||
if (base)
|
||||
free (base);
|
||||
if (result)
|
||||
free (result);
|
||||
free (base);
|
||||
free (result);
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -1013,8 +1000,7 @@ eval_string_if (const char *text, struct t_eval_context *eval_context)
|
||||
return strdup ("");
|
||||
tmp = eval_expression_condition (condition, eval_context);
|
||||
rc = eval_is_true (tmp);
|
||||
if (tmp)
|
||||
free (tmp);
|
||||
free (tmp);
|
||||
if (rc)
|
||||
{
|
||||
/*
|
||||
@@ -1269,8 +1255,7 @@ eval_hdata_get_value (struct t_hdata *hdata, void *pointer, const char *path,
|
||||
property = string_strndup (pos + 1,
|
||||
pos_open_paren - pos - 1);
|
||||
ptr_value = hashtable_get_string (hashtable, property);
|
||||
if (property)
|
||||
free (property);
|
||||
free (property);
|
||||
value = (ptr_value) ? strdup (ptr_value) : NULL;
|
||||
break;
|
||||
}
|
||||
@@ -1323,8 +1308,7 @@ eval_hdata_get_value (struct t_hdata *hdata, void *pointer, const char *path,
|
||||
goto end;
|
||||
|
||||
hdata = hook_hdata_get (NULL, hdata_name);
|
||||
if (value)
|
||||
free (value);
|
||||
free (value);
|
||||
value = eval_hdata_get_value (hdata,
|
||||
pointer,
|
||||
pos + 1,
|
||||
@@ -1332,8 +1316,7 @@ eval_hdata_get_value (struct t_hdata *hdata, void *pointer, const char *path,
|
||||
}
|
||||
|
||||
end:
|
||||
if (var_name)
|
||||
free (var_name);
|
||||
free (var_name);
|
||||
|
||||
EVAL_DEBUG_RESULT(1, value);
|
||||
|
||||
@@ -1442,10 +1425,8 @@ eval_string_hdata (const char *text, struct t_eval_context *eval_context)
|
||||
value = eval_hdata_get_value (hdata, pointer, pos_vars, eval_context);
|
||||
|
||||
end:
|
||||
if (hdata_name)
|
||||
free (hdata_name);
|
||||
if (pointer_name)
|
||||
free (pointer_name);
|
||||
free (hdata_name);
|
||||
free (pointer_name);
|
||||
|
||||
return (value) ? value : strdup ("");
|
||||
}
|
||||
@@ -1548,8 +1529,7 @@ eval_syntax_highlight (const char *text, struct t_eval_context *eval_context)
|
||||
|
||||
value = eval_replace_vars (text, eval_context);
|
||||
value2 = eval_syntax_highlight_colorize (value);
|
||||
if (value)
|
||||
free (value);
|
||||
free (value);
|
||||
|
||||
eval_context->syntax_highlight--;
|
||||
|
||||
@@ -2273,8 +2253,7 @@ eval_expression_condition (const char *expr,
|
||||
tmp_value = eval_expression_condition (sub_expr, eval_context);
|
||||
free (sub_expr);
|
||||
rc = eval_is_true (tmp_value);
|
||||
if (tmp_value)
|
||||
free (tmp_value);
|
||||
free (tmp_value);
|
||||
/*
|
||||
* if rc == 0 with "&&" or rc == 1 with "||", no need to
|
||||
* evaluate second sub-expression, just return the rc
|
||||
@@ -2292,8 +2271,7 @@ eval_expression_condition (const char *expr,
|
||||
}
|
||||
tmp_value = eval_expression_condition (pos, eval_context);
|
||||
rc = eval_is_true (tmp_value);
|
||||
if (tmp_value)
|
||||
free (tmp_value);
|
||||
free (tmp_value);
|
||||
value = strdup ((rc) ? EVAL_STR_TRUE : EVAL_STR_FALSE);
|
||||
goto end;
|
||||
}
|
||||
@@ -2347,10 +2325,8 @@ eval_expression_condition (const char *expr,
|
||||
}
|
||||
free (sub_expr);
|
||||
value = eval_compare (tmp_value, comp, tmp_value2, eval_context);
|
||||
if (tmp_value)
|
||||
free (tmp_value);
|
||||
if (tmp_value2)
|
||||
free (tmp_value2);
|
||||
free (tmp_value);
|
||||
free (tmp_value2);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
@@ -2397,8 +2373,7 @@ eval_expression_condition (const char *expr,
|
||||
tmp_value2 = malloc (length);
|
||||
if (!tmp_value2)
|
||||
{
|
||||
if (tmp_value)
|
||||
free (tmp_value);
|
||||
free (tmp_value);
|
||||
goto end;
|
||||
}
|
||||
tmp_value2[0] = '\0';
|
||||
@@ -2408,8 +2383,7 @@ eval_expression_condition (const char *expr,
|
||||
strcat (tmp_value2, pos + 1);
|
||||
free (expr2);
|
||||
expr2 = tmp_value2;
|
||||
if (tmp_value)
|
||||
free (tmp_value);
|
||||
free (tmp_value);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2419,8 +2393,7 @@ eval_expression_condition (const char *expr,
|
||||
value = eval_replace_vars (expr2, eval_context);
|
||||
|
||||
end:
|
||||
if (expr2)
|
||||
free (expr2);
|
||||
free (expr2);
|
||||
|
||||
EVAL_DEBUG_RESULT(1, value);
|
||||
|
||||
@@ -2549,8 +2522,7 @@ eval_replace_regex (const char *string, regex_t *regex, const char *replace,
|
||||
free (result);
|
||||
result = result2;
|
||||
|
||||
if (str_replace)
|
||||
free (str_replace);
|
||||
free (str_replace);
|
||||
|
||||
if (end)
|
||||
break;
|
||||
@@ -2777,8 +2749,7 @@ eval_expression (const char *expr, struct t_hashtable *pointers,
|
||||
/* evaluate as condition (return a boolean: "0" or "1") */
|
||||
value = eval_expression_condition (expr, eval_context);
|
||||
rc = eval_is_true (value);
|
||||
if (value)
|
||||
free (value);
|
||||
free (value);
|
||||
value = strdup ((rc) ? EVAL_STR_TRUE : EVAL_STR_FALSE);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -321,8 +321,7 @@ hashtable_free_key (struct t_hashtable *hashtable,
|
||||
case HASHTABLE_STRING:
|
||||
case HASHTABLE_BUFFER:
|
||||
case HASHTABLE_TIME:
|
||||
if (item->key)
|
||||
free (item->key);
|
||||
free (item->key);
|
||||
break;
|
||||
case HASHTABLE_POINTER:
|
||||
break;
|
||||
@@ -354,8 +353,7 @@ hashtable_free_value (struct t_hashtable *hashtable,
|
||||
case HASHTABLE_STRING:
|
||||
case HASHTABLE_BUFFER:
|
||||
case HASHTABLE_TIME:
|
||||
if (item->value)
|
||||
free (item->value);
|
||||
free (item->value);
|
||||
break;
|
||||
case HASHTABLE_POINTER:
|
||||
break;
|
||||
@@ -638,10 +636,8 @@ hashtable_map_string (struct t_hashtable *hashtable,
|
||||
key,
|
||||
value);
|
||||
|
||||
if (key)
|
||||
free (key);
|
||||
if (value)
|
||||
free (value);
|
||||
free (key);
|
||||
free (value);
|
||||
|
||||
ptr_item = ptr_next_created_item;
|
||||
}
|
||||
@@ -1285,8 +1281,7 @@ hashtable_free (struct t_hashtable *hashtable)
|
||||
|
||||
hashtable_remove_all (hashtable);
|
||||
free (hashtable->htable);
|
||||
if (hashtable->keys_values)
|
||||
free (hashtable->keys_values);
|
||||
free (hashtable->keys_values);
|
||||
free (hashtable);
|
||||
}
|
||||
|
||||
|
||||
+9
-18
@@ -59,10 +59,8 @@ hdata_free_var_cb (struct t_hashtable *hashtable, const void *key, void *value)
|
||||
var = (struct t_hdata_var *)value;
|
||||
if (var)
|
||||
{
|
||||
if (var->array_size)
|
||||
free (var->array_size);
|
||||
if (var->hdata_name)
|
||||
free (var->hdata_name);
|
||||
free (var->array_size);
|
||||
free (var->hdata_name);
|
||||
free (var);
|
||||
}
|
||||
}
|
||||
@@ -642,8 +640,7 @@ hdata_search (struct t_hdata *hdata,
|
||||
/* evaluate expression */
|
||||
result = eval_expression (search, pointers2, extra_vars, options2);
|
||||
rc = eval_is_true (result);
|
||||
if (result)
|
||||
free (result);
|
||||
free (result);
|
||||
if (rc)
|
||||
{
|
||||
ret_pointer = pointer;
|
||||
@@ -1113,8 +1110,7 @@ hdata_compare (struct t_hdata *hdata, void *pointer1, void *pointer2,
|
||||
pos_open_paren - pos - 1);
|
||||
ptr_value1 = (void *)hashtable_get_string (hashtable1, property);
|
||||
ptr_value2 = (void *)hashtable_get_string (hashtable2, property);
|
||||
if (property)
|
||||
free (property);
|
||||
free (property);
|
||||
type1 = HASHTABLE_STRING;
|
||||
type2 = HASHTABLE_STRING;
|
||||
}
|
||||
@@ -1200,8 +1196,7 @@ hdata_compare (struct t_hdata *hdata, void *pointer1, void *pointer2,
|
||||
}
|
||||
|
||||
end:
|
||||
if (var_name)
|
||||
free (var_name);
|
||||
free (var_name);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -1275,8 +1270,7 @@ hdata_set (struct t_hdata *hdata, void *pointer, const char *name,
|
||||
break;
|
||||
case WEECHAT_HDATA_STRING:
|
||||
ptr_string = (char **)(pointer + var->offset);
|
||||
if (*ptr_string)
|
||||
free (*ptr_string);
|
||||
free (*ptr_string);
|
||||
*ptr_string = (value) ? strdup (value) : NULL;
|
||||
return 1;
|
||||
break;
|
||||
@@ -1412,14 +1406,11 @@ hdata_free (struct t_hdata *hdata)
|
||||
|
||||
if (hdata->hash_var)
|
||||
hashtable_free (hdata->hash_var);
|
||||
if (hdata->var_prev)
|
||||
free (hdata->var_prev);
|
||||
if (hdata->var_next)
|
||||
free (hdata->var_next);
|
||||
free (hdata->var_prev);
|
||||
free (hdata->var_next);
|
||||
if (hdata->hash_list)
|
||||
hashtable_free (hdata->hash_list);
|
||||
if (hdata->name)
|
||||
free (hdata->name);
|
||||
free (hdata->name);
|
||||
|
||||
free (hdata);
|
||||
}
|
||||
|
||||
@@ -532,8 +532,7 @@ hook_callback_end (struct t_hook *hook, struct t_hook_exec_cb *hook_exec_cb)
|
||||
plugin_get_name (hook->plugin),
|
||||
(hook->subplugin) ? hook->subplugin : "-",
|
||||
str_diff);
|
||||
if (str_diff)
|
||||
free (str_diff);
|
||||
free (str_diff);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -571,8 +570,7 @@ hook_set (struct t_hook *hook, const char *property, const char *value)
|
||||
|
||||
if (strcmp (property, "subplugin") == 0)
|
||||
{
|
||||
if (hook->subplugin)
|
||||
free (hook->subplugin);
|
||||
free (hook->subplugin);
|
||||
hook->subplugin = strdup (value);
|
||||
}
|
||||
else if (strcmp (property, "stdin") == 0)
|
||||
@@ -907,8 +905,7 @@ hook_add_to_infolist (struct t_infolist *infolist, struct t_hook *pointer,
|
||||
hook_add_to_infolist_type (infolist, i, pos_arguments);
|
||||
}
|
||||
|
||||
if (type)
|
||||
free (type);
|
||||
free (type);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -595,8 +595,7 @@ infolist_var_free (struct t_infolist_item *item,
|
||||
(var->next_var)->prev_var = var->prev_var;
|
||||
|
||||
/* free data */
|
||||
if (var->name)
|
||||
free (var->name);
|
||||
free (var->name);
|
||||
if (((var->type == INFOLIST_INTEGER)
|
||||
|| (var->type == INFOLIST_STRING)
|
||||
|| (var->type == INFOLIST_BUFFER)
|
||||
@@ -643,8 +642,7 @@ infolist_item_free (struct t_infolist *infolist,
|
||||
{
|
||||
infolist_var_free (item, item->vars);
|
||||
}
|
||||
if (item->fields)
|
||||
free (item->fields);
|
||||
free (item->fields);
|
||||
|
||||
free (item);
|
||||
|
||||
|
||||
+5
-10
@@ -221,10 +221,8 @@ input_exec_command (struct t_gui_buffer *buffer,
|
||||
}
|
||||
|
||||
end:
|
||||
if (command)
|
||||
free (command);
|
||||
if (command_name)
|
||||
free (command_name);
|
||||
free (command);
|
||||
free (command_name);
|
||||
|
||||
if (new_commands_allowed)
|
||||
string_free_split (new_commands_allowed);
|
||||
@@ -359,10 +357,8 @@ input_data (struct t_gui_buffer *buffer, const char *data,
|
||||
}
|
||||
|
||||
end:
|
||||
if (buffer_full_name)
|
||||
free (buffer_full_name);
|
||||
if (new_data)
|
||||
free (new_data);
|
||||
free (buffer_full_name);
|
||||
free (new_data);
|
||||
|
||||
return rc;
|
||||
}
|
||||
@@ -403,8 +399,7 @@ input_data_timer_cb (const void *pointer, void *data, int remaining_calls)
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (timer_args[i])
|
||||
free (timer_args[i]);
|
||||
free (timer_args[i]);
|
||||
}
|
||||
free (timer_args);
|
||||
|
||||
|
||||
@@ -301,8 +301,7 @@ weelist_set (struct t_weelist_item *item, const char *value)
|
||||
if (!item || !value)
|
||||
return;
|
||||
|
||||
if (item->data)
|
||||
free (item->data);
|
||||
free (item->data);
|
||||
item->data = strdup (value);
|
||||
}
|
||||
|
||||
@@ -402,8 +401,7 @@ weelist_remove (struct t_weelist *weelist, struct t_weelist_item *item)
|
||||
(item->next_item)->prev_item = item->prev_item;
|
||||
|
||||
/* free data */
|
||||
if (item->data)
|
||||
free (item->data);
|
||||
free (item->data);
|
||||
free (item);
|
||||
weelist->items = new_items;
|
||||
|
||||
|
||||
+7
-14
@@ -228,8 +228,7 @@ network_load_user_ca_files (int force_display)
|
||||
ca_path);
|
||||
}
|
||||
}
|
||||
if (ca_path)
|
||||
free (ca_path);
|
||||
free (ca_path);
|
||||
}
|
||||
|
||||
end:
|
||||
@@ -1416,10 +1415,8 @@ network_connect_child (struct t_hook *hook_connect)
|
||||
}
|
||||
|
||||
end:
|
||||
if (status_with_string)
|
||||
free (status_with_string);
|
||||
if (res_reorder)
|
||||
free (res_reorder);
|
||||
free (status_with_string);
|
||||
free (res_reorder);
|
||||
if (res_local)
|
||||
freeaddrinfo (res_local);
|
||||
if (res_remote)
|
||||
@@ -1734,8 +1731,7 @@ network_connect_child_read_cb (const void *pointer, void *data, int fd)
|
||||
gnutls_strerror (rc),
|
||||
cb_ip_address);
|
||||
unhook (hook_connect);
|
||||
if (cb_ip_address)
|
||||
free (cb_ip_address);
|
||||
free (cb_ip_address);
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
fcntl (HOOK_CONNECT(hook_connect, sock), F_SETFL,
|
||||
@@ -1756,8 +1752,7 @@ network_connect_child_read_cb (const void *pointer, void *data, int fd)
|
||||
"Error in the certificate.",
|
||||
cb_ip_address);
|
||||
unhook (hook_connect);
|
||||
if (cb_ip_address)
|
||||
free (cb_ip_address);
|
||||
free (cb_ip_address);
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
#endif /* LIBGNUTLS_VERSION_NUMBER < 0x02090a */
|
||||
@@ -1808,10 +1803,8 @@ network_connect_child_read_cb (const void *pointer, void *data, int fd)
|
||||
unhook (hook_connect);
|
||||
}
|
||||
|
||||
if (cb_error)
|
||||
free (cb_error);
|
||||
if (cb_ip_address)
|
||||
free (cb_ip_address);
|
||||
free (cb_error);
|
||||
free (cb_ip_address);
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -181,8 +181,7 @@ proxy_set_name (struct t_proxy *proxy, const char *name)
|
||||
snprintf (option_name, length, "%s.password", name);
|
||||
config_file_option_rename (proxy->options[PROXY_OPTION_PASSWORD], option_name);
|
||||
|
||||
if (proxy->name)
|
||||
free (proxy->name);
|
||||
free (proxy->name);
|
||||
proxy->name = strdup (name);
|
||||
|
||||
free (option_name);
|
||||
@@ -528,8 +527,7 @@ proxy_use_temp_proxies ()
|
||||
{
|
||||
next_temp_proxy = weechat_temp_proxies->next_proxy;
|
||||
|
||||
if (weechat_temp_proxies->name)
|
||||
free (weechat_temp_proxies->name);
|
||||
free (weechat_temp_proxies->name);
|
||||
free (weechat_temp_proxies);
|
||||
|
||||
weechat_temp_proxies = next_temp_proxy;
|
||||
@@ -560,8 +558,7 @@ proxy_free (struct t_proxy *proxy)
|
||||
last_weechat_proxy = proxy->prev_proxy;
|
||||
|
||||
/* free data */
|
||||
if (proxy->name)
|
||||
free (proxy->name);
|
||||
free (proxy->name);
|
||||
for (i = 0; i < PROXY_NUM_OPTIONS; i++)
|
||||
{
|
||||
config_file_option_free (proxy->options[i], 1);
|
||||
|
||||
@@ -336,8 +336,7 @@ secure_config_data_read_cb (const void *pointer, void *data,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (decrypted)
|
||||
free (decrypted);
|
||||
free (decrypted);
|
||||
if (gui_init_ok)
|
||||
{
|
||||
gui_chat_printf (NULL,
|
||||
|
||||
+5
-10
@@ -251,10 +251,8 @@ encrypt_end:
|
||||
gcry_cipher_close (*hd_cipher);
|
||||
free (hd_cipher);
|
||||
}
|
||||
if (key)
|
||||
free (key);
|
||||
if (hash_and_data)
|
||||
free (hash_and_data);
|
||||
free (key);
|
||||
free (hash_and_data);
|
||||
|
||||
return rc;
|
||||
}
|
||||
@@ -403,10 +401,8 @@ decrypt_end:
|
||||
gcry_cipher_close (*hd_cipher);
|
||||
free (hd_cipher);
|
||||
}
|
||||
if (key)
|
||||
free (key);
|
||||
if (decrypted_hash_data)
|
||||
free (decrypted_hash_data);
|
||||
free (key);
|
||||
free (decrypted_hash_data);
|
||||
|
||||
return rc;
|
||||
}
|
||||
@@ -484,8 +480,7 @@ secure_decrypt_data_not_decrypted (const char *passphrase)
|
||||
keys[i]);
|
||||
num_ok++;
|
||||
}
|
||||
if (decrypted)
|
||||
free (decrypted);
|
||||
free (decrypted);
|
||||
free (buffer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,8 +225,7 @@ signal_exec_command (int signal_index, const char *command)
|
||||
log_printf ("Signal %s received, executing command: \"%s\"",
|
||||
(signal_upper) ? signal_upper : str_signal,
|
||||
command_eval);
|
||||
if (signal_upper)
|
||||
free (signal_upper);
|
||||
free (signal_upper);
|
||||
(void) input_data (gui_buffer_search_main (),
|
||||
command_eval, NULL, 0, 0);
|
||||
free (command_eval);
|
||||
|
||||
+14
-29
@@ -1179,10 +1179,8 @@ string_eval_path_home (const char *path,
|
||||
path3 = eval_expression (path2, pointers, extra_vars, options);
|
||||
|
||||
end:
|
||||
if (path1)
|
||||
free (path1);
|
||||
if (path2)
|
||||
free (path2);
|
||||
free (path1);
|
||||
free (path2);
|
||||
|
||||
return path3;
|
||||
}
|
||||
@@ -2086,8 +2084,7 @@ string_replace_regex_get_replace (const char *string, regmatch_t *regex_match,
|
||||
result2 = realloc (result, length + 1);
|
||||
if (!result2)
|
||||
{
|
||||
if (modified_replace)
|
||||
free (modified_replace);
|
||||
free (modified_replace);
|
||||
free (result);
|
||||
return NULL;
|
||||
}
|
||||
@@ -2097,8 +2094,7 @@ string_replace_regex_get_replace (const char *string, regmatch_t *regex_match,
|
||||
length_current += length_add;
|
||||
result[length_current] = '\0';
|
||||
}
|
||||
if (modified_replace)
|
||||
free (modified_replace);
|
||||
free (modified_replace);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -2219,8 +2215,7 @@ string_replace_regex (const char *string, void *regex, const char *replace,
|
||||
free (result);
|
||||
result = result2;
|
||||
|
||||
if (str_replace)
|
||||
free (str_replace);
|
||||
free (str_replace);
|
||||
|
||||
if (end)
|
||||
break;
|
||||
@@ -2982,8 +2977,7 @@ string_split_command (const char *command, char separator)
|
||||
array2 = realloc (array, (arr_idx + 1) * sizeof (array[0]));
|
||||
if (!array2)
|
||||
{
|
||||
if (array)
|
||||
free (array);
|
||||
free (array);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -3297,8 +3291,7 @@ string_fprintf (FILE *file, const char *data, ...)
|
||||
buf2 = string_iconv_from_internal (NULL, vbuffer);
|
||||
num_written = fprintf (file, "%s", (buf2) ? buf2 : vbuffer);
|
||||
rc = (num_written == (int)strlen ((buf2) ? buf2 : vbuffer)) ? 1 : 0;
|
||||
if (buf2)
|
||||
free (buf2);
|
||||
free (buf2);
|
||||
free (vbuffer);
|
||||
}
|
||||
|
||||
@@ -3445,8 +3438,7 @@ string_parse_size (const char *size)
|
||||
}
|
||||
|
||||
end:
|
||||
if (str_number)
|
||||
free (str_number);
|
||||
free (str_number);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -4036,13 +4028,9 @@ string_hex_dump (const char *data, int data_size, int bytes_per_line,
|
||||
}
|
||||
|
||||
end:
|
||||
if (str_hexa)
|
||||
free (str_hexa);
|
||||
if (str_ascii)
|
||||
free (str_ascii);
|
||||
if (str_line)
|
||||
free (str_line);
|
||||
|
||||
free (str_hexa);
|
||||
free (str_ascii);
|
||||
free (str_line);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@@ -4374,10 +4362,8 @@ string_replace_with_callback (const char *string,
|
||||
result2 = realloc (result, length);
|
||||
if (!result2)
|
||||
{
|
||||
if (result)
|
||||
free (result);
|
||||
if (key)
|
||||
free (key);
|
||||
free (result);
|
||||
free (key);
|
||||
free (value);
|
||||
return NULL;
|
||||
}
|
||||
@@ -4397,8 +4383,7 @@ string_replace_with_callback (const char *string,
|
||||
if (errors)
|
||||
(*errors)++;
|
||||
}
|
||||
if (key)
|
||||
free (key);
|
||||
free (key);
|
||||
}
|
||||
else
|
||||
result[index_result++] = string[index_string++];
|
||||
|
||||
@@ -712,13 +712,9 @@ upgrade_file_read_object (struct t_upgrade_file *upgrade_file)
|
||||
end:
|
||||
if (infolist)
|
||||
infolist_free (infolist);
|
||||
if (name)
|
||||
free (name);
|
||||
if (value_str)
|
||||
free (value_str);
|
||||
if (buffer)
|
||||
free (buffer);
|
||||
|
||||
free (name);
|
||||
free (value_str);
|
||||
free (buffer);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -749,8 +745,7 @@ upgrade_file_read (struct t_upgrade_file *upgrade_file)
|
||||
{
|
||||
UPGRADE_ERROR(_("read - bad signature (upgrade file format may have "
|
||||
"changed since last version)"), "");
|
||||
if (signature)
|
||||
free (signature);
|
||||
free (signature);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -775,12 +770,10 @@ upgrade_file_close (struct t_upgrade_file *upgrade_file)
|
||||
if (!upgrade_file)
|
||||
return;
|
||||
|
||||
if (upgrade_file->filename)
|
||||
free (upgrade_file->filename);
|
||||
free (upgrade_file->filename);
|
||||
if (upgrade_file->file)
|
||||
fclose (upgrade_file->file);
|
||||
if (upgrade_file->callback_read_data)
|
||||
free (upgrade_file->callback_read_data);
|
||||
free (upgrade_file->callback_read_data);
|
||||
|
||||
/* remove upgrade file list */
|
||||
if (upgrade_file->prev_upgrade)
|
||||
|
||||
@@ -462,8 +462,7 @@ upgrade_weechat_read_buffer (struct t_infolist *infolist)
|
||||
upgrade_set_current_buffer = ptr_buffer;
|
||||
|
||||
/* name for upgrade */
|
||||
if (ptr_buffer->plugin_name_for_upgrade)
|
||||
free (ptr_buffer->plugin_name_for_upgrade);
|
||||
free (ptr_buffer->plugin_name_for_upgrade);
|
||||
ptr_buffer->plugin_name_for_upgrade =
|
||||
strdup (infolist_string (infolist, "plugin_name"));
|
||||
|
||||
@@ -471,14 +470,12 @@ upgrade_weechat_read_buffer (struct t_infolist *infolist)
|
||||
gui_buffer_build_full_name (ptr_buffer);
|
||||
|
||||
/* old full name */
|
||||
if (ptr_buffer->old_full_name)
|
||||
free (ptr_buffer->old_full_name);
|
||||
free (ptr_buffer->old_full_name);
|
||||
str = infolist_string (infolist, "old_full_name");
|
||||
ptr_buffer->old_full_name = (str) ? strdup (str) : NULL;
|
||||
|
||||
/* short name */
|
||||
if (ptr_buffer->short_name)
|
||||
free (ptr_buffer->short_name);
|
||||
free (ptr_buffer->short_name);
|
||||
str = infolist_string (infolist, "short_name");
|
||||
ptr_buffer->short_name = (str) ? strdup (str) : NULL;
|
||||
|
||||
@@ -521,8 +518,7 @@ upgrade_weechat_read_buffer (struct t_infolist *infolist)
|
||||
/* title (not for main buffer, because there's the latest version) */
|
||||
if (!main_buffer)
|
||||
{
|
||||
if (ptr_buffer->title)
|
||||
free (ptr_buffer->title);
|
||||
free (ptr_buffer->title);
|
||||
str = infolist_string (infolist, "title");
|
||||
ptr_buffer->title = (str) ? strdup (str) : NULL;
|
||||
}
|
||||
|
||||
@@ -159,8 +159,7 @@ hook_command_run_exec (struct t_gui_buffer *buffer, const char *command)
|
||||
hook_callback_end (ptr_hook, &hook_exec_cb);
|
||||
if (rc == WEECHAT_RC_OK_EAT)
|
||||
{
|
||||
if (command2)
|
||||
free (command2);
|
||||
free (command2);
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
@@ -169,8 +168,7 @@ hook_command_run_exec (struct t_gui_buffer *buffer, const char *command)
|
||||
ptr_hook = next_hook;
|
||||
}
|
||||
|
||||
if (command2)
|
||||
free (command2);
|
||||
free (command2);
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@@ -999,10 +999,8 @@ hook_command_free_data (struct t_hook *hook)
|
||||
{
|
||||
for (i = 0; i < HOOK_COMMAND(hook, cplt_num_templates); i++)
|
||||
{
|
||||
if (HOOK_COMMAND(hook, cplt_templates)[i])
|
||||
free (HOOK_COMMAND(hook, cplt_templates)[i]);
|
||||
if (HOOK_COMMAND(hook, cplt_templates_static)[i])
|
||||
free (HOOK_COMMAND(hook, cplt_templates_static)[i]);
|
||||
free (HOOK_COMMAND(hook, cplt_templates)[i]);
|
||||
free (HOOK_COMMAND(hook, cplt_templates_static)[i]);
|
||||
string_free_split (HOOK_COMMAND(hook, cplt_template_args)[i]);
|
||||
}
|
||||
free (HOOK_COMMAND(hook, cplt_templates));
|
||||
@@ -1083,12 +1081,10 @@ hook_command_add_to_infolist (struct t_infolist_item *item,
|
||||
if (!infolist_new_var_string (item, "args_description_nls",
|
||||
(args_desc_nls) ? args_desc_nls : ""))
|
||||
{
|
||||
if (args_desc_nls)
|
||||
free (args_desc_nls);
|
||||
free (args_desc_nls);
|
||||
return 0;
|
||||
}
|
||||
if (args_desc_nls)
|
||||
free (args_desc_nls);
|
||||
free (args_desc_nls);
|
||||
if (!infolist_new_var_string (item, "completion", HOOK_COMMAND(hook, completion)))
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -176,8 +176,7 @@ hook_line_exec (struct t_gui_line *line)
|
||||
str_tags = string_rebuild_split_string (
|
||||
(const char **)line->data->tags_array, ",", 0, -1);
|
||||
HASHTABLE_SET_STR_NOT_NULL("tags", str_tags);
|
||||
if (str_tags)
|
||||
free (str_tags);
|
||||
free (str_tags);
|
||||
HASHTABLE_SET_INT("displayed", line->data->displayed);
|
||||
HASHTABLE_SET_INT("notify_level", line->data->notify_level);
|
||||
HASHTABLE_SET_INT("highlight", line->data->highlight);
|
||||
|
||||
@@ -136,8 +136,7 @@ hook_print_exec (struct t_gui_buffer *buffer, struct t_gui_line *line)
|
||||
message_no_color = gui_color_decode (line->data->message, NULL);
|
||||
if (!message_no_color)
|
||||
{
|
||||
if (prefix_no_color)
|
||||
free (prefix_no_color);
|
||||
free (prefix_no_color);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -180,10 +179,8 @@ hook_print_exec (struct t_gui_buffer *buffer, struct t_gui_line *line)
|
||||
ptr_hook = next_hook;
|
||||
}
|
||||
|
||||
if (prefix_no_color)
|
||||
free (prefix_no_color);
|
||||
if (message_no_color)
|
||||
free (message_no_color);
|
||||
free (prefix_no_color);
|
||||
free (message_no_color);
|
||||
|
||||
hook_exec_end ();
|
||||
}
|
||||
|
||||
@@ -177,14 +177,10 @@ hook_process_hashtable (struct t_weechat_plugin *plugin,
|
||||
return new_hook;
|
||||
|
||||
error:
|
||||
if (stdout_buffer)
|
||||
free (stdout_buffer);
|
||||
if (stderr_buffer)
|
||||
free (stderr_buffer);
|
||||
if (new_hook)
|
||||
free (new_hook);
|
||||
if (new_hook_process)
|
||||
free (new_hook_process);
|
||||
free (stdout_buffer);
|
||||
free (stderr_buffer);
|
||||
free (new_hook);
|
||||
free (new_hook_process);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -347,10 +347,8 @@ hook_url (struct t_weechat_plugin *plugin,
|
||||
return new_hook;
|
||||
|
||||
error:
|
||||
if (new_hook)
|
||||
free (new_hook);
|
||||
if (new_hook_url)
|
||||
free (new_hook_url);
|
||||
free (new_hook);
|
||||
free (new_hook_url);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
+13
-26
@@ -301,8 +301,7 @@ weechat_parse_args (int argc, char *argv[])
|
||||
break;
|
||||
case 'd': /* -d / --dir */
|
||||
weechat_home_temp = 0;
|
||||
if (weechat_home_force)
|
||||
free (weechat_home_force);
|
||||
free (weechat_home_force);
|
||||
weechat_home_force = strdup (optarg);
|
||||
break;
|
||||
case 't': /* -t / --temp-dir */
|
||||
@@ -324,13 +323,11 @@ weechat_parse_args (int argc, char *argv[])
|
||||
weechat_shutdown (EXIT_SUCCESS, 0);
|
||||
break;
|
||||
case 'p': /* -p / --no-plugin */
|
||||
if (weechat_force_plugin_autoload)
|
||||
free (weechat_force_plugin_autoload);
|
||||
free (weechat_force_plugin_autoload);
|
||||
weechat_force_plugin_autoload = strdup ("!*");
|
||||
break;
|
||||
case 'P': /* -P / --plugins */
|
||||
if (weechat_force_plugin_autoload)
|
||||
free (weechat_force_plugin_autoload);
|
||||
free (weechat_force_plugin_autoload);
|
||||
weechat_force_plugin_autoload = strdup (optarg);
|
||||
break;
|
||||
case 'r': /* -r / --run-command */
|
||||
@@ -576,28 +573,18 @@ weechat_shutdown (int return_code, int crash)
|
||||
dir_remove_home_dirs ();
|
||||
}
|
||||
|
||||
if (weechat_argv0)
|
||||
free (weechat_argv0);
|
||||
if (weechat_home_force)
|
||||
free (weechat_home_force);
|
||||
if (weechat_config_dir)
|
||||
free (weechat_config_dir);
|
||||
if (weechat_data_dir)
|
||||
free (weechat_data_dir);
|
||||
if (weechat_state_dir)
|
||||
free (weechat_state_dir);
|
||||
if (weechat_cache_dir)
|
||||
free (weechat_cache_dir);
|
||||
if (weechat_runtime_dir)
|
||||
free (weechat_runtime_dir);
|
||||
if (weechat_local_charset)
|
||||
free (weechat_local_charset);
|
||||
if (weechat_force_plugin_autoload)
|
||||
free (weechat_force_plugin_autoload);
|
||||
free (weechat_argv0);
|
||||
free (weechat_home_force);
|
||||
free (weechat_config_dir);
|
||||
free (weechat_data_dir);
|
||||
free (weechat_state_dir);
|
||||
free (weechat_cache_dir);
|
||||
free (weechat_runtime_dir);
|
||||
free (weechat_local_charset);
|
||||
free (weechat_force_plugin_autoload);
|
||||
if (weechat_startup_commands)
|
||||
weelist_free (weechat_startup_commands);
|
||||
if (weechat_doc_gen_path)
|
||||
free (weechat_doc_gen_path);
|
||||
free (weechat_doc_gen_path);
|
||||
|
||||
if (crash)
|
||||
abort ();
|
||||
|
||||
Reference in New Issue
Block a user