1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-27 05:16:38 +02:00

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

This commit is contained in:
Sébastien Helleu
2024-04-25 00:18:30 +02:00
parent b56b34711d
commit e73bff95fa
55 changed files with 394 additions and 802 deletions
+1 -4
View File
@@ -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
View File
@@ -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;
}
+7 -16
View File
@@ -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
View File
@@ -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
View File
@@ -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);
+3 -6
View File
@@ -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;
}
+1 -2
View File
@@ -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
View File
@@ -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
View File
@@ -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, &regex, "-", '$', NULL, NULL);
regfree (&regex);
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
View File
@@ -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
+5 -10
View File
@@ -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
View File
@@ -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);
}
+3 -6
View File
@@ -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;
}
+2 -4
View File
@@ -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
View File
@@ -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);
+2 -4
View File
@@ -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
View File
@@ -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;
}
+3 -6
View File
@@ -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);
+1 -2
View File
@@ -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
View File
@@ -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);
}
}
+1 -2
View File
@@ -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
View File
@@ -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++];
+6 -13
View File
@@ -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)
+4 -8
View File
@@ -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;
}
+2 -4
View File
@@ -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;
}
+4 -8
View File
@@ -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;
+1 -2
View File
@@ -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);
+3 -6
View File
@@ -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 ();
}
+4 -8
View File
@@ -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;
}
+2 -4
View File
@@ -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
View File
@@ -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 ();
+1 -2
View File
@@ -397,8 +397,7 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
(output) ? output : utf_char2);
if (reverse_video)
wattroff (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, A_REVERSE);
if (output)
free (output);
free (output);
if (gui_window_current_emphasis)
{
+11 -22
View File
@@ -459,8 +459,7 @@ gui_chat_display_word_raw (struct t_gui_window *window, struct t_gui_line *line,
wattroff (GUI_WINDOW_OBJECTS(window)->win_chat,
A_REVERSE);
}
if (output)
free (output);
free (output);
if (gui_window_current_emphasis)
{
@@ -764,8 +763,7 @@ gui_chat_display_day_changed (struct t_gui_window *window,
0, simulate, 0, 0);
window->win_chat_cursor_x = window->win_chat_width;
if (message_with_color)
free (message_with_color);
free (message_with_color);
}
/*
@@ -1240,8 +1238,7 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
if (window->win_chat_cursor_y < window->coords_size)
window->coords[window->win_chat_cursor_y].prefix_x2 = window->win_chat_cursor_x - 1;
if (prefix_highlighted)
free (prefix_highlighted);
free (prefix_highlighted);
if (!simulate)
{
@@ -1371,8 +1368,7 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
simulate, 0, 0);
}
}
if (ptr_prefix)
free (ptr_prefix);
free (ptr_prefix);
}
/*
@@ -1652,12 +1648,9 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
&lines_displayed, simulate);
}
if (message_nick_offline)
free (message_nick_offline);
if (message_with_tags)
free (message_with_tags);
if (message_with_search)
free (message_with_search);
free (message_nick_offline);
free (message_with_tags);
free (message_with_search);
/* display message if day has changed after this line */
if ((line->data->date != 0)
@@ -1809,10 +1802,8 @@ gui_chat_display_line_y (struct t_gui_window *window, struct t_gui_line *line,
gui_window_clrtoeol (GUI_WINDOW_OBJECTS(window)->win_chat);
}
if (message_with_tags)
free (message_with_tags);
if (message_with_search)
free (message_with_search);
free (message_with_tags);
free (message_with_search);
}
/*
@@ -2163,10 +2154,8 @@ gui_chat_get_bare_line (struct t_gui_line *line)
}
end:
if (prefix)
free (prefix);
if (message)
free (message);
free (prefix);
free (message);
return str_line;
}
+3 -6
View File
@@ -763,10 +763,8 @@ gui_color_init_pairs_weechat ()
init_pair (i, i, -1);
}
}
if (foregrounds)
free (foregrounds);
if (backgrounds)
free (backgrounds);
free (foregrounds);
free (backgrounds);
}
}
@@ -1533,8 +1531,7 @@ gui_color_palette_free (struct t_gui_color_palette *color_palette)
if (!color_palette)
return;
if (color_palette->alias)
free (color_palette->alias);
free (color_palette->alias);
free (color_palette);
}
+1 -2
View File
@@ -482,8 +482,7 @@ gui_key_flush (int paste)
}
}
if (input_old)
free (input_old);
free (input_old);
}
/* prepare incomplete UTF-8 char for next iteration */
+1 -2
View File
@@ -498,8 +498,7 @@ gui_main_end (int clean_exit)
gui_filter_free_all ();
/* free clipboard buffer */
if (gui_input_clipboard)
free (gui_input_clipboard);
free (gui_input_clipboard);
/* delete layouts */
gui_layout_remove_all ();
+2 -4
View File
@@ -611,8 +611,7 @@ gui_bar_item_custom_free_data (struct t_gui_bar_item_custom *item)
{
int i;
if (item->name)
free (item->name);
free (item->name);
for (i = 0; i < GUI_BAR_ITEM_CUSTOM_NUM_OPTIONS; i++)
{
if (item->options[i])
@@ -654,8 +653,7 @@ gui_bar_item_custom_free (struct t_gui_bar_item_custom *item)
gui_bar_item_update (name);
if (name)
free (name);
free (name);
}
/*
+7 -14
View File
@@ -442,8 +442,7 @@ gui_bar_item_get_value (struct t_gui_bar *bar, struct t_gui_window *window,
ptr_item->name,
plugin_get_name (ptr_item->plugin),
str_diff);
if (str_diff)
free (str_diff);
free (str_diff);
}
}
}
@@ -459,8 +458,7 @@ gui_bar_item_get_value (struct t_gui_bar *bar, struct t_gui_window *window,
result = string_dyn_alloc (128);
if (!result)
{
if (item_value)
free (item_value);
free (item_value);
return NULL;
}
@@ -532,8 +530,7 @@ gui_bar_item_get_value (struct t_gui_bar *bar, struct t_gui_window *window,
string_dyn_concat (result, bar->items_suffix[item][subitem], -1);
}
if (item_value)
free (item_value);
free (item_value);
return string_dyn_free (result, 0);
}
@@ -730,10 +727,8 @@ gui_bar_item_free (struct t_gui_bar_item *item)
last_gui_bar_item = item->prev_item;
/* free data */
if (item->name)
free (item->name);
if (item->build_callback_data)
free (item->build_callback_data);
free (item->name);
free (item->build_callback_data);
free (item);
}
@@ -1016,8 +1011,7 @@ gui_bar_item_input_text_cb (const void *pointer, void *data,
"input_text_display_with_cursor",
str_buffer,
(ptr_input) ? ptr_input : "");
if (ptr_input)
free (ptr_input);
free (ptr_input);
ptr_input = ptr_input2;
}
@@ -1734,8 +1728,7 @@ gui_bar_item_hotlist_cb (const void *pointer, void *data,
}
}
if (buffer_without_name_displayed)
free (buffer_without_name_displayed);
free (buffer_without_name_displayed);
hotlist_suffix = CONFIG_STRING(config_look_hotlist_suffix);
if (hotlist_suffix[0]
+4 -8
View File
@@ -516,8 +516,7 @@ error:
{
for (i = 0; i < bar_window->items_count; i++)
{
if (bar_window->items_content[i])
free (bar_window->items_content[i]);
free (bar_window->items_content[i]);
}
free (bar_window->items_content);
bar_window->items_content = NULL;
@@ -526,8 +525,7 @@ error:
{
for (i = 0; i < bar_window->items_count; i++)
{
if (bar_window->items_num_lines[i])
free (bar_window->items_num_lines[i]);
free (bar_window->items_num_lines[i]);
}
free (bar_window->items_num_lines);
bar_window->items_num_lines = NULL;
@@ -536,8 +534,7 @@ error:
{
for (i = 0; i < bar_window->items_count; i++)
{
if (bar_window->items_refresh_needed[i])
free (bar_window->items_refresh_needed[i]);
free (bar_window->items_refresh_needed[i]);
}
free (bar_window->items_refresh_needed);
bar_window->items_refresh_needed = NULL;
@@ -814,8 +811,7 @@ gui_bar_window_content_get_with_filling (struct t_gui_bar_window *bar_window,
(item_value) ? item_value : ptr_content,
-1);
first_sub_item = 0;
if (item_value)
free (item_value);
free (item_value);
if (item_is_spacer)
(*num_spacers)++;
else
+14 -28
View File
@@ -418,8 +418,7 @@ gui_bar_check_conditions (struct t_gui_bar *bar,
result = eval_expression (conditions, pointers, extra_vars, options);
rc = eval_is_true (result);
if (result)
free (result);
free (result);
if (pointers)
hashtable_free (pointers);
if (extra_vars)
@@ -448,8 +447,7 @@ gui_bar_check_conditions (struct t_gui_bar *bar,
else
rc = 1;
if (str_displayed)
free (str_displayed);
free (str_displayed);
return rc;
}
@@ -693,23 +691,15 @@ gui_bar_free_items_arrays (struct t_gui_bar *bar)
string_free_split (bar->items_array[i]);
for (j = 0; j < bar->items_subcount[i]; j++)
{
if (bar->items_buffer[i][j])
free (bar->items_buffer[i][j]);
if (bar->items_prefix[i][j])
free (bar->items_prefix[i][j]);
if (bar->items_name[i][j])
free (bar->items_name[i][j]);
if (bar->items_suffix[i][j])
free (bar->items_suffix[i][j]);
free (bar->items_buffer[i][j]);
free (bar->items_prefix[i][j]);
free (bar->items_name[i][j]);
free (bar->items_suffix[i][j]);
}
if (bar->items_buffer[i])
free (bar->items_buffer[i]);
if (bar->items_prefix[i])
free (bar->items_prefix[i]);
if (bar->items_name[i])
free (bar->items_name[i]);
if (bar->items_suffix[i])
free (bar->items_suffix[i]);
free (bar->items_buffer[i]);
free (bar->items_prefix[i]);
free (bar->items_name[i]);
free (bar->items_suffix[i]);
}
if (bar->items_array)
{
@@ -1220,8 +1210,7 @@ gui_bar_set_name (struct t_gui_bar *bar, const char *name)
config_file_option_rename (bar->options[i], option_name);
}
if (bar->name)
free (bar->name);
free (bar->name);
bar->name = strdup (name);
}
@@ -1918,8 +1907,7 @@ gui_bar_use_temp_bars ()
{
next_temp_bar = gui_temp_bars->next_bar;
if (gui_temp_bars->name)
free (gui_temp_bars->name);
free (gui_temp_bars->name);
free (gui_temp_bars);
gui_temp_bars = next_temp_bar;
@@ -2191,8 +2179,7 @@ gui_bar_scroll (struct t_gui_bar *bar, struct t_gui_window *window,
}
}
if (str)
free (str);
free (str);
return 1;
}
@@ -2229,8 +2216,7 @@ gui_bar_free (struct t_gui_bar *bar)
last_gui_bar = bar->prev_bar;
/* free data */
if (bar->name)
free (bar->name);
free (bar->name);
for (i = 0; i < GUI_BAR_NUM_OPTIONS; i++)
{
if (bar->options[i])
+32 -64
View File
@@ -240,8 +240,7 @@ gui_buffer_build_full_name (struct t_gui_buffer *buffer)
if (!buffer)
return;
if (buffer->full_name)
free (buffer->full_name);
free (buffer->full_name);
length = strlen (gui_buffer_get_plugin_name (buffer)) + 1 +
strlen (buffer->name) + 1;
buffer->full_name = malloc (length);
@@ -1277,8 +1276,7 @@ gui_buffer_string_replace_local_var (struct t_gui_buffer *buffer,
}
if (!result2)
{
if (result)
free (result);
free (result);
free (local_var);
return NULL;
}
@@ -1629,12 +1627,10 @@ gui_buffer_set_name (struct t_gui_buffer *buffer, const char *name)
* save the old full name so that hooks on signal "buffer_renamed"
* can read the old name
*/
if (buffer->old_full_name)
free (buffer->old_full_name);
free (buffer->old_full_name);
buffer->old_full_name = strdup (buffer->full_name);
if (buffer->name)
free (buffer->name);
free (buffer->name);
buffer->name = strdup (name);
gui_buffer_build_full_name (buffer);
@@ -1743,8 +1739,7 @@ gui_buffer_set_title (struct t_gui_buffer *buffer, const char *new_title)
return;
}
if (buffer->title)
free (buffer->title);
free (buffer->title);
buffer->title = (new_title && new_title[0]) ? strdup (new_title) : NULL;
(void) gui_buffer_send_signal (buffer,
@@ -1825,8 +1820,7 @@ gui_buffer_set_highlight_words (struct t_gui_buffer *buffer,
if (!buffer)
return;
if (buffer->highlight_words)
free (buffer->highlight_words);
free (buffer->highlight_words);
buffer->highlight_words = (new_highlight_words && new_highlight_words[0]) ?
strdup (new_highlight_words) : NULL;
}
@@ -3690,8 +3684,7 @@ gui_buffer_close (struct t_gui_buffer *buffer)
}
gui_hotlist_remove_buffer (buffer, 1);
if (buffer->hotlist_removed)
free (buffer->hotlist_removed);
free (buffer->hotlist_removed);
if (gui_hotlist_initial_buffer == buffer)
gui_hotlist_initial_buffer = NULL;
@@ -3709,10 +3702,8 @@ gui_buffer_close (struct t_gui_buffer *buffer)
/* free all lines */
gui_line_free_all (buffer);
if (buffer->own_lines)
free (buffer->own_lines);
if (buffer->mixed_lines)
free (buffer->mixed_lines);
free (buffer->own_lines);
free (buffer->mixed_lines);
/* free some data */
gui_buffer_undo_free_all (buffer);
@@ -3727,59 +3718,42 @@ gui_buffer_close (struct t_gui_buffer *buffer)
&buffer->keys_count, 0);
gui_buffer_local_var_remove_all (buffer);
hashtable_free (buffer->local_variables);
if (buffer->plugin_name_for_upgrade)
free (buffer->plugin_name_for_upgrade);
if (buffer->name)
free (buffer->name);
if (buffer->full_name)
free (buffer->full_name);
if (buffer->old_full_name)
free (buffer->old_full_name);
if (buffer->short_name)
free (buffer->short_name);
if (buffer->title)
free (buffer->title);
if (buffer->input_buffer)
free (buffer->input_buffer);
if (buffer->input_undo_snap)
free (buffer->input_undo_snap);
if (buffer->text_search_input)
free (buffer->text_search_input);
free (buffer->plugin_name_for_upgrade);
free (buffer->name);
free (buffer->full_name);
free (buffer->old_full_name);
free (buffer->short_name);
free (buffer->title);
free (buffer->input_buffer);
free (buffer->input_undo_snap);
free (buffer->text_search_input);
if (buffer->text_search_regex_compiled)
{
regfree (buffer->text_search_regex_compiled);
free (buffer->text_search_regex_compiled);
}
if (buffer->highlight_words)
free (buffer->highlight_words);
if (buffer->highlight_disable_regex)
free (buffer->highlight_disable_regex);
free (buffer->highlight_words);
free (buffer->highlight_disable_regex);
if (buffer->highlight_disable_regex_compiled)
{
regfree (buffer->highlight_disable_regex_compiled);
free (buffer->highlight_disable_regex_compiled);
}
if (buffer->highlight_regex)
free (buffer->highlight_regex);
free (buffer->highlight_regex);
if (buffer->highlight_regex_compiled)
{
regfree (buffer->highlight_regex_compiled);
free (buffer->highlight_regex_compiled);
}
if (buffer->highlight_tags_restrict)
free (buffer->highlight_tags_restrict);
free (buffer->highlight_tags_restrict);
if (buffer->highlight_tags_restrict_array)
string_free_split_tags (buffer->highlight_tags_restrict_array);
if (buffer->highlight_tags)
free (buffer->highlight_tags);
free (buffer->highlight_tags);
if (buffer->highlight_tags_array)
string_free_split_tags (buffer->highlight_tags_array);
if (buffer->input_callback_data)
free (buffer->input_callback_data);
if (buffer->close_callback_data)
free (buffer->close_callback_data);
if (buffer->nickcmp_callback_data)
free (buffer->nickcmp_callback_data);
free (buffer->input_callback_data);
free (buffer->close_callback_data);
free (buffer->nickcmp_callback_data);
/* remove buffer from buffers list */
if (buffer->prev_buffer)
@@ -4880,8 +4854,7 @@ gui_buffer_undo_free (struct t_gui_buffer *buffer,
}
/* free data */
if (undo->data)
free (undo->data);
free (undo->data);
/* remove undo from list */
if (undo->prev_undo)
@@ -4956,8 +4929,7 @@ gui_buffer_input_move_to_buffer (struct t_gui_buffer *from_buffer,
return;
/* move input_buffer */
if (to_buffer->input_buffer)
free (to_buffer->input_buffer);
free (to_buffer->input_buffer);
to_buffer->input_buffer = from_buffer->input_buffer;
to_buffer->input_buffer_alloc = from_buffer->input_buffer_alloc;
to_buffer->input_buffer_size = from_buffer->input_buffer_size;
@@ -5526,10 +5498,8 @@ gui_buffer_dump_hexa (struct t_gui_buffer *buffer)
num_line,
(prefix_without_colors) ? prefix_without_colors : "(null)",
(message_without_colors) ? message_without_colors : "(null)");
if (prefix_without_colors)
free (prefix_without_colors);
if (message_without_colors)
free (message_without_colors);
free (prefix_without_colors);
free (message_without_colors);
tags = string_rebuild_split_string ((const char **)ptr_line->data->tags_array,
",",
0, -1);
@@ -5537,8 +5507,7 @@ gui_buffer_dump_hexa (struct t_gui_buffer *buffer)
(tags) ? tags : "(none)",
ptr_line->data->displayed,
ptr_line->data->highlight);
if (tags)
free (tags);
free (tags);
snprintf (buf, sizeof (buf), "%s", ctime (&ptr_line->data->date));
buf[strlen (buf) - 1] = '\0';
log_printf (" date: %lld = %s",
@@ -5775,8 +5744,7 @@ gui_buffer_print_log ()
ptr_line->data->prefix);
log_printf (" data: '%s'",
ptr_line->data->message);
if (tags)
free (tags);
free (tags);
ptr_line = ptr_line->next_line;
}
+8 -16
View File
@@ -548,8 +548,7 @@ gui_chat_change_time_format ()
{
if (ptr_line->data->date != 0)
{
if (ptr_line->data->str_time)
free (ptr_line->data->str_time);
free (ptr_line->data->str_time);
ptr_line->data->str_time = gui_chat_get_time_string (
ptr_line->data->date,
ptr_line->data->date_usec,
@@ -768,8 +767,7 @@ gui_chat_printf_datetime_tags_internal (struct t_gui_buffer *buffer,
}
new_line->data->prefix_length = gui_chat_strlen_screen (
new_line->data->prefix);
if (new_line->data->message)
free (new_line->data->message);
free (new_line->data->message);
new_line->data->message = strdup (ptr_msg);
}
}
@@ -784,12 +782,9 @@ gui_chat_printf_datetime_tags_internal (struct t_gui_buffer *buffer,
gui_buffer_ask_chat_refresh (new_line->data->buffer, 1);
if (string)
free (string);
if (modifier_data)
free (modifier_data);
if (new_string)
free (new_string);
free (string);
free (modifier_data);
free (new_string);
return;
@@ -799,12 +794,9 @@ no_print:
gui_line_free_data (new_line);
free (new_line);
}
if (string)
free (string);
if (modifier_data)
free (modifier_data);
if (new_string)
free (new_string);
free (string);
free (modifier_data);
free (new_string);
}
/*
+4 -8
View File
@@ -528,12 +528,10 @@ gui_color_get_custom (const char *color_name)
color_bg);
}
if (str_fg)
free (str_fg);
free (str_fg);
}
if (color_attr)
free (color_attr);
free (color_attr);
return color[index_color];
}
@@ -1187,8 +1185,7 @@ gui_color_decode_ansi_cb (void *data, const char *text)
end:
if (items)
string_free_split (items);
if (text2)
free (text2);
free (text2);
return (output) ? output : strdup ("");
}
@@ -1868,8 +1865,7 @@ gui_color_free (struct t_gui_color *color)
if (!color)
return;
if (color->string)
free (color->string);
free (color->string);
free (color);
}
+10 -20
View File
@@ -99,8 +99,7 @@ gui_completion_word_free_cb (void *data,
completion_word = (struct t_gui_completion_word *)pointer;
if (completion_word->word)
free (completion_word->word);
free (completion_word->word);
free (completion_word);
}
@@ -211,16 +210,13 @@ gui_completion_partial_list_add (struct t_gui_completion *completion,
void
gui_completion_free_data (struct t_gui_completion *completion)
{
if (completion->base_command)
free (completion->base_command);
free (completion->base_command);
completion->base_command = NULL;
if (completion->base_word)
free (completion->base_word);
free (completion->base_word);
completion->base_word = NULL;
if (completion->args)
free (completion->args);
free (completion->args);
completion->args = NULL;
if (completion->list)
@@ -229,8 +225,7 @@ gui_completion_free_data (struct t_gui_completion *completion)
completion->list = NULL;
}
if (completion->word_found)
free (completion->word_found);
free (completion->word_found);
completion->word_found = NULL;
if (completion->partial_list)
@@ -1265,8 +1260,7 @@ gui_completion_complete (struct t_gui_completion *completion)
{
if ((!completion->word_found) || word_found_seen)
{
if (completion->word_found)
free (completion->word_found);
free (completion->word_found);
completion->word_found = strdup (ptr_completion_word->word);
completion->word_found_is_nick =
ptr_completion_word->nick_completion;
@@ -1468,8 +1462,7 @@ gui_completion_auto (struct t_gui_completion *completion)
completion,
(default_completion) ? default_completion : "",
NULL);
if (default_completion)
free (default_completion);
free (default_completion);
}
gui_completion_complete (completion);
}
@@ -1495,8 +1488,7 @@ gui_completion_search (struct t_gui_completion *completion, const char *data,
/* if new completion => look for base word */
if (real_position != completion->position)
{
if (completion->word_found)
free (completion->word_found);
free (completion->word_found);
completion->word_found = NULL;
completion->word_found_is_nick = 0;
gui_completion_find_context (completion, data, real_position);
@@ -1509,8 +1501,7 @@ gui_completion_search (struct t_gui_completion *completion, const char *data,
switch (completion->context)
{
case GUI_COMPLETION_NULL:
if (old_word_found)
free (old_word_found);
free (old_word_found);
return 0;
case GUI_COMPLETION_COMMAND:
gui_completion_command (completion);
@@ -1545,8 +1536,7 @@ gui_completion_search (struct t_gui_completion *completion, const char *data,
utf8_strlen (completion->base_word);
}
}
if (old_word_found)
free (old_word_found);
free (old_word_found);
return 1;
}
+6 -12
View File
@@ -445,8 +445,7 @@ gui_filter_new (int enabled, const char *name, const char *buffer_name,
_("invalid regular expression (%s)"),
buf);
gui_filter_new_error (name, str_error);
if (regex_prefix)
free (regex_prefix);
free (regex_prefix);
if (regex1)
{
regfree (regex1);
@@ -458,8 +457,7 @@ gui_filter_new (int enabled, const char *name, const char *buffer_name,
}
}
if (regex_prefix)
free (regex_prefix);
free (regex_prefix);
}
/* create new filter */
@@ -540,18 +538,14 @@ gui_filter_free (struct t_gui_filter *filter)
WEECHAT_HOOK_SIGNAL_POINTER, filter);
/* free data */
if (filter->name)
free (filter->name);
if (filter->buffer_name)
free (filter->buffer_name);
free (filter->name);
free (filter->buffer_name);
if (filter->buffers)
string_free_split (filter->buffers);
if (filter->tags)
free (filter->tags);
free (filter->tags);
if (filter->tags_array)
string_free_split_tags (filter->tags_array);
if (filter->regex)
free (filter->regex);
free (filter->regex);
if (filter->regex_prefix)
{
regfree (filter->regex_prefix);
+10 -20
View File
@@ -100,18 +100,12 @@ gui_focus_get_info (int x, int y)
void
gui_focus_free_info (struct t_gui_focus_info *focus_info)
{
if (focus_info->chat_word)
free (focus_info->chat_word);
if (focus_info->chat_focused_line)
free (focus_info->chat_focused_line);
if (focus_info->chat_focused_line_bol)
free (focus_info->chat_focused_line_bol);
if (focus_info->chat_focused_line_eol)
free (focus_info->chat_focused_line_eol);
if (focus_info->chat_bol)
free (focus_info->chat_bol);
if (focus_info->chat_eol)
free (focus_info->chat_eol);
free (focus_info->chat_word);
free (focus_info->chat_focused_line);
free (focus_info->chat_focused_line_bol);
free (focus_info->chat_focused_line_eol);
free (focus_info->chat_bol);
free (focus_info->chat_eol);
free (focus_info);
}
@@ -226,14 +220,10 @@ gui_focus_to_hashtable (struct t_gui_focus_info *focus_info, const char *key)
HASHTABLE_SET_STR_NOT_NULL("_chat_line_nick", nick);
HASHTABLE_SET_STR_NOT_NULL("_chat_line_prefix", str_prefix);
HASHTABLE_SET_STR_NOT_NULL("_chat_line_message", str_message);
if (str_time)
free (str_time);
if (str_prefix)
free (str_prefix);
if (str_tags)
free (str_tags);
if (str_message)
free (str_message);
free (str_time);
free (str_prefix);
free (str_tags);
free (str_message);
}
else
{
+6 -12
View File
@@ -68,8 +68,7 @@ gui_history_buffer_remove_oldest (struct t_gui_buffer *buffer)
if (buffer->ptr_history == buffer->last_history)
buffer->ptr_history = ptr_history;
((buffer->last_history)->prev_history)->next_history = NULL;
if (buffer->last_history->text)
free (buffer->last_history->text);
free (buffer->last_history->text);
free (buffer->last_history);
buffer->last_history = ptr_history;
@@ -140,8 +139,7 @@ gui_history_global_remove_oldest ()
if (gui_history_ptr == last_gui_history)
gui_history_ptr = ptr_history;
(last_gui_history->prev_history)->next_history = NULL;
if (last_gui_history->text)
free (last_gui_history->text);
free (last_gui_history->text);
free (last_gui_history);
last_gui_history = ptr_history;
@@ -207,8 +205,7 @@ gui_history_add (struct t_gui_buffer *buffer, const char *string)
gui_history_global_add ((string2) ? string2 : string);
}
if (string2)
free (string2);
free (string2);
}
/*
@@ -310,8 +307,7 @@ gui_history_global_free ()
while (gui_history)
{
ptr_history = gui_history->next_history;
if (gui_history->text)
free (gui_history->text);
free (gui_history->text);
free (gui_history);
gui_history = ptr_history;
}
@@ -337,8 +333,7 @@ gui_history_buffer_free (struct t_gui_buffer *buffer)
while (buffer->history)
{
ptr_history = buffer->history->next_history;
if (buffer->history->text)
free (buffer->history->text);
free (buffer->history->text);
free (buffer->history);
buffer->history = ptr_history;
}
@@ -378,8 +373,7 @@ gui_history_hdata_history_update_cb (void *data,
{
/* update history */
ptr_history = (struct t_gui_history *)pointer;
if (ptr_history->text)
free (ptr_history->text);
free (ptr_history->text);
ptr_history->text = strdup (text);
}
else
+2 -4
View File
@@ -155,8 +155,7 @@ gui_hotlist_free (struct t_gui_hotlist **hotlist,
if (save_removed_hotlist)
{
if (ptr_hotlist->buffer->hotlist_removed)
free (ptr_hotlist->buffer->hotlist_removed);
free (ptr_hotlist->buffer->hotlist_removed);
ptr_hotlist->buffer->hotlist_removed = gui_hotlist_dup (ptr_hotlist);
ptr_hotlist->buffer->hotlist_removed->prev_hotlist = NULL;
ptr_hotlist->buffer->hotlist_removed->next_hotlist = NULL;
@@ -437,8 +436,7 @@ gui_hotlist_add (struct t_gui_buffer *buffer,
gui_hotlist_hashtable_add_conditions_vars,
gui_hotlist_hashtable_add_conditions_options);
rc = (value && (strcmp (value, "1") == 0));
if (value)
free (value);
free (value);
if (!rc)
return NULL;
}
+3 -6
View File
@@ -1625,8 +1625,7 @@ gui_input_history_previous (struct t_gui_window *window,
{
/* replace text in history with current input */
window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
if ((*ptr_history)->prev_history->text)
free ((*ptr_history)->prev_history->text);
free ((*ptr_history)->prev_history->text);
(*ptr_history)->prev_history->text =
strdup (window->buffer->input_buffer);
}
@@ -1675,8 +1674,7 @@ gui_input_history_next (struct t_gui_window *window,
{
/* replace text in history with current input */
window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
if ((*ptr_history)->text)
free ((*ptr_history)->text);
free ((*ptr_history)->text);
(*ptr_history)->text = strdup (window->buffer->input_buffer);
*ptr_history = (*ptr_history)->prev_history;
@@ -1892,8 +1890,7 @@ gui_input_insert (struct t_gui_buffer *buffer, const char *args)
gui_input_text_changed_modifier_and_signal (buffer,
1, /* save undo */
1); /* stop completion */
if (args2)
free (args2);
free (args2);
}
/*
+11 -22
View File
@@ -1161,10 +1161,8 @@ gui_key_set_areas (struct t_gui_key *key)
&(key->area_name[area]));
}
if (areas[0])
free (areas[0]);
if (areas[1])
free (areas[1]);
free (areas[0]);
free (areas[1]);
}
/*
@@ -1413,8 +1411,7 @@ gui_key_option_change_cb (const void *pointer, void *data,
if (!ptr_key)
return;
if (ptr_key->command)
free (ptr_key->command);
free (ptr_key->command);
ptr_key->command = strdup (CONFIG_STRING(option));
}
@@ -1568,8 +1565,7 @@ error:
key,
gui_key_context_string[context]);
}
if (key_fixed)
free (key_fixed);
free (key_fixed);
if (ptr_option)
config_file_option_free (ptr_option, 0);
return NULL;
@@ -2607,10 +2603,8 @@ end_no_input:
rc = 0;
end:
if (key_name)
free (key_name);
if (key_name_alias)
free (key_name_alias);
free (key_name);
free (key_name_alias);
return rc;
}
@@ -2642,19 +2636,15 @@ gui_key_free (int context,
}
/* free memory */
if (key->key)
free (key->key);
free (key->key);
if (key->chunks)
string_free_split (key->chunks);
for (i = 0; i < 2; i++)
{
if (key->area_name[i])
free (key->area_name[i]);
free (key->area_name[i]);
}
if (key->area_key)
free (key->area_key);
if (key->command)
free (key->command);
free (key->area_key);
free (key->command);
/* remove key from keys list */
if (key->prev_key)
@@ -3063,8 +3053,7 @@ gui_key_end ()
int context;
/* free key buffer */
if (gui_key_buffer)
free (gui_key_buffer);
free (gui_key_buffer);
for (context = 0; context < GUI_KEY_NUM_CONTEXTS; context++)
{
+6 -12
View File
@@ -144,8 +144,7 @@ gui_layout_rename (struct t_gui_layout *layout, const char *new_name)
if (!layout || !new_name || !new_name[0])
return;
if (layout->name)
free (layout->name);
free (layout->name);
layout->name = strdup (new_name);
}
@@ -171,10 +170,8 @@ gui_layout_buffer_remove (struct t_gui_layout *layout,
layout->last_layout_buffer = layout_buffer->prev_layout;
/* free data */
if (layout_buffer->plugin_name)
free (layout_buffer->plugin_name);
if (layout_buffer->buffer_name)
free (layout_buffer->buffer_name);
free (layout_buffer->plugin_name);
free (layout_buffer->buffer_name);
free (layout_buffer);
}
@@ -389,10 +386,8 @@ gui_layout_window_remove (struct t_gui_layout_window *layout_window)
gui_layout_window_remove (layout_window->child2);
/* free data */
if (layout_window->plugin_name)
free (layout_window->plugin_name);
if (layout_window->buffer_name)
free (layout_window->buffer_name);
free (layout_window->plugin_name);
free (layout_window->buffer_name);
free (layout_window);
}
@@ -827,8 +822,7 @@ gui_layout_free (struct t_gui_layout *layout)
gui_layout_window_remove (layout->layout_windows);
/* free data */
if (layout->name)
free (layout->name);
free (layout->name);
free (layout);
}
+16 -32
View File
@@ -743,10 +743,8 @@ gui_line_match_regex (struct t_gui_line_data *line_data, regex_t *regex_prefix,
match_message = 0;
}
if (prefix)
free (prefix);
if (message)
free (message);
free (prefix);
free (message);
return (match_prefix && match_message);
}
@@ -1053,8 +1051,7 @@ gui_line_has_highlight (struct t_gui_line *line)
rc = string_has_highlight (ptr_msg_no_color,
(highlight_words) ?
highlight_words : line->data->buffer->highlight_words);
if (highlight_words)
free (highlight_words);
free (highlight_words);
if (rc)
goto end;
@@ -1063,8 +1060,7 @@ gui_line_has_highlight (struct t_gui_line *line)
rc = string_has_highlight (ptr_msg_no_color,
(highlight_words) ?
highlight_words : CONFIG_STRING(config_look_highlight));
if (highlight_words)
free (highlight_words);
free (highlight_words);
if (rc)
goto end;
@@ -1083,8 +1079,7 @@ gui_line_has_highlight (struct t_gui_line *line)
}
end:
if (msg_no_color)
free (msg_no_color);
free (msg_no_color);
return rc;
}
@@ -1249,13 +1244,11 @@ gui_line_add_to_list (struct t_gui_lines *lines,
void
gui_line_free_data (struct t_gui_line *line)
{
if (line->data->str_time)
free (line->data->str_time);
free (line->data->str_time);
gui_line_tags_free (line->data);
if (line->data->prefix)
string_shared_free (line->data->prefix);
if (line->data->message)
free (line->data->message);
free (line->data->message);
free (line->data);
line->data = NULL;
@@ -1732,8 +1725,7 @@ gui_line_hook_update (struct t_gui_line *line,
if (error && !error[0] && (value >= 0))
{
line->data->date = (time_t)value;
if (line->data->str_time)
free (line->data->str_time);
free (line->data->str_time);
line->data->str_time = gui_chat_get_time_string (
line->data->date,
line->data->date_usec,
@@ -1749,8 +1741,7 @@ gui_line_hook_update (struct t_gui_line *line,
if (error && !error[0] && (value >= 0) && (value <= 999999))
{
line->data->date_usec = (int)value;
if (line->data->str_time)
free (line->data->str_time);
free (line->data->str_time);
line->data->str_time = gui_chat_get_time_string (
line->data->date,
line->data->date_usec,
@@ -1780,8 +1771,7 @@ gui_line_hook_update (struct t_gui_line *line,
ptr_value2 = hashtable_get (hashtable2, "str_time");
if (ptr_value2 && (!ptr_value || (strcmp (ptr_value, ptr_value2) != 0)))
{
if (line->data->str_time)
free (line->data->str_time);
free (line->data->str_time);
line->data->str_time = (ptr_value2) ? strdup (ptr_value2) : NULL;
}
@@ -1818,11 +1808,9 @@ gui_line_hook_update (struct t_gui_line *line,
if (pos_newline)
pos_newline[0] = '\0';
}
if (line->data->message)
free (line->data->message);
free (line->data->message);
line->data->message = (new_message) ? strdup (new_message) : NULL;
if (new_message)
free (new_message);
free (new_message);
}
max_notify_level = gui_line_get_max_notify_level (line);
@@ -2090,8 +2078,7 @@ gui_line_clear (struct t_gui_line *line)
line->data->prefix_length = 0;
line->data->notify_level = 0;
line->data->highlight = 0;
if (line->data->message)
free (line->data->message);
free (line->data->message);
line->data->message = strdup ("");
}
@@ -2274,8 +2261,7 @@ gui_line_hdata_line_data_update_cb (void *data,
if (value)
{
hdata_set (hdata, pointer, "date", value);
if (line_data->str_time)
free (line_data->str_time);
free (line_data->str_time);
line_data->str_time = gui_chat_get_time_string (
line_data->date,
line_data->date_usec,
@@ -2291,8 +2277,7 @@ gui_line_hdata_line_data_update_cb (void *data,
if (value)
{
hdata_set (hdata, pointer, "date_usec", value);
if (line_data->str_time)
free (line_data->str_time);
free (line_data->str_time);
line_data->str_time = gui_chat_get_time_string (
line_data->date,
line_data->date_usec,
@@ -2355,8 +2340,7 @@ gui_line_hdata_line_data_update_cb (void *data,
hdata_set (hdata, pointer, "message", new_value);
rc++;
update_coords = 1;
if (new_value)
free (new_value);
free (new_value);
}
if (rc > 0)
+3 -6
View File
@@ -326,10 +326,8 @@ end:
result = strdup ((ptr_result) ? ptr_result : default_color);
if (list_colors)
string_free_split (list_colors);
if (nickname2)
free (nickname2);
if (nickname3)
free (nickname3);
free (nickname2);
free (nickname3);
return result;
}
@@ -362,7 +360,6 @@ gui_nick_find_color (const char *nickname, int case_range, const char *colors)
color = gui_nick_find_color_name (nickname, case_range, colors);
ptr_result = gui_color_get_custom (color);
if (color)
free (color);
free (color);
return (ptr_result) ? strdup (ptr_result) : NULL;
}
+2 -4
View File
@@ -620,8 +620,7 @@ gui_nicklist_remove_nick (struct t_gui_buffer *buffer,
gui_nicklist_send_signal ("nicklist_nick_removed", buffer, nick_removed);
if (nick_removed)
free (nick_removed);
free (nick_removed);
}
/*
@@ -692,8 +691,7 @@ gui_nicklist_remove_group (struct t_gui_buffer *buffer,
gui_nicklist_send_signal ("nicklist_group_removed", buffer, group_removed);
if (group_removed)
free (group_removed);
free (group_removed);
}
/*
+3 -6
View File
@@ -1056,17 +1056,14 @@ gui_window_free (struct t_gui_window *window)
}
/* free other data */
if (window->layout_plugin_name)
free (window->layout_plugin_name);
if (window->layout_buffer_name)
free (window->layout_buffer_name);
free (window->layout_plugin_name);
free (window->layout_buffer_name);
/* remove scroll list */
gui_window_scroll_free_all (window);
/* free coords */
if (window->coords)
free (window->coords);
free (window->coords);
/* remove window from windows list */
if (window->prev_window)