mirror of
https://github.com/weechat/weechat.git
synced 2026-07-06 17:53:13 +02:00
core: remove check of NULL pointers before calling free() (issue #865)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user