core: check that pointers received in arguments are not NULL in "free" functions
Functions: - hdata_free - infolist_var_free - infolist_item_free - infolist_free - string_shared_free - gui_window_objects_free - gui_color_free - gui_completion_free - gui_filter_free - gui_history_buffer_free - gui_hotlist_free - gui_key_free - gui_lines_free - gui_line_tags_free - gui_line_free - gui_window_tree_free - gui_window_scroll_freev2.8-utf8proc
parent
eebb0547e2
commit
0d059add9a
|
@ -1062,6 +1062,9 @@ hdata_get_string (struct t_hdata *hdata, const char *property)
|
|||
void
|
||||
hdata_free (struct t_hdata *hdata)
|
||||
{
|
||||
if (!hdata)
|
||||
return;
|
||||
|
||||
if (hdata->hash_var)
|
||||
hashtable_free (hdata->hash_var);
|
||||
if (hdata->var_prev)
|
||||
|
|
|
@ -584,6 +584,9 @@ infolist_var_free (struct t_infolist_item *item,
|
|||
{
|
||||
struct t_infolist_var *new_vars;
|
||||
|
||||
if (!item || !var)
|
||||
return;
|
||||
|
||||
/* remove var */
|
||||
if (item->last_var == var)
|
||||
item->last_var = var->prev_var;
|
||||
|
@ -625,6 +628,9 @@ infolist_item_free (struct t_infolist *infolist,
|
|||
{
|
||||
struct t_infolist_item *new_items;
|
||||
|
||||
if (!infolist || !item)
|
||||
return;
|
||||
|
||||
/* remove var */
|
||||
if (infolist->last_item == item)
|
||||
infolist->last_item = item->prev_item;
|
||||
|
@ -661,6 +667,9 @@ infolist_free (struct t_infolist *infolist)
|
|||
{
|
||||
struct t_infolist *new_weechat_infolists;
|
||||
|
||||
if (!infolist)
|
||||
return;
|
||||
|
||||
/* remove list */
|
||||
if (last_weechat_infolist == infolist)
|
||||
last_weechat_infolist = infolist->prev_infolist;
|
||||
|
|
|
@ -3184,6 +3184,9 @@ string_shared_free (const char *string)
|
|||
{
|
||||
string_shared_count_t *ptr_count;
|
||||
|
||||
if (!string)
|
||||
return;
|
||||
|
||||
ptr_count = (string_shared_count_t *)(string - sizeof (string_shared_count_t));
|
||||
|
||||
(*ptr_count)--;
|
||||
|
|
|
@ -146,6 +146,9 @@ gui_window_objects_init (struct t_gui_window *window)
|
|||
void
|
||||
gui_window_objects_free (struct t_gui_window *window, int free_separators)
|
||||
{
|
||||
if (!window)
|
||||
return;
|
||||
|
||||
if (GUI_WINDOW_OBJECTS(window)->win_chat)
|
||||
{
|
||||
delwin (GUI_WINDOW_OBJECTS(window)->win_chat);
|
||||
|
|
|
@ -1147,13 +1147,13 @@ gui_color_emphasize (const char *string,
|
|||
void
|
||||
gui_color_free (struct t_gui_color *color)
|
||||
{
|
||||
if (color)
|
||||
{
|
||||
if (color->string)
|
||||
free (color->string);
|
||||
if (!color)
|
||||
return;
|
||||
|
||||
free (color);
|
||||
}
|
||||
if (color->string)
|
||||
free (color->string);
|
||||
|
||||
free (color);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -200,7 +200,11 @@ gui_completion_free_data (struct t_gui_completion *completion)
|
|||
void
|
||||
gui_completion_free (struct t_gui_completion *completion)
|
||||
{
|
||||
if (!completion)
|
||||
return;
|
||||
|
||||
gui_completion_free_data (completion);
|
||||
|
||||
free (completion);
|
||||
}
|
||||
|
||||
|
|
|
@ -467,6 +467,9 @@ gui_filter_free (struct t_gui_filter *filter)
|
|||
{
|
||||
int i;
|
||||
|
||||
if (!filter)
|
||||
return;
|
||||
|
||||
(void) hook_signal_send ("filter_removing",
|
||||
WEECHAT_HOOK_SIGNAL_POINTER, filter);
|
||||
|
||||
|
|
|
@ -201,6 +201,9 @@ gui_history_buffer_free (struct t_gui_buffer *buffer)
|
|||
{
|
||||
struct t_gui_history *ptr_history;
|
||||
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
while (buffer->history)
|
||||
{
|
||||
ptr_history = buffer->history->next_history;
|
||||
|
|
|
@ -96,6 +96,9 @@ gui_hotlist_free (struct t_gui_hotlist **hotlist,
|
|||
{
|
||||
struct t_gui_hotlist *new_hotlist;
|
||||
|
||||
if (!ptr_hotlist)
|
||||
return;
|
||||
|
||||
/* remove hotlist from queue */
|
||||
if (*last_hotlist == ptr_hotlist)
|
||||
*last_hotlist = ptr_hotlist->prev_hotlist;
|
||||
|
|
|
@ -1435,6 +1435,9 @@ gui_key_free (struct t_gui_key **keys, struct t_gui_key **last_key,
|
|||
{
|
||||
int i;
|
||||
|
||||
if (!key)
|
||||
return;
|
||||
|
||||
/* free memory */
|
||||
if (key->key)
|
||||
free (key->key);
|
||||
|
|
|
@ -83,6 +83,9 @@ gui_lines_alloc ()
|
|||
void
|
||||
gui_lines_free (struct t_gui_lines *lines)
|
||||
{
|
||||
if (!lines)
|
||||
return;
|
||||
|
||||
free (lines);
|
||||
}
|
||||
|
||||
|
@ -112,6 +115,9 @@ gui_line_tags_alloc (struct t_gui_line_data *line_data, const char *tags)
|
|||
void
|
||||
gui_line_tags_free (struct t_gui_line_data *line_data)
|
||||
{
|
||||
if (!line_data)
|
||||
return;
|
||||
|
||||
if (line_data->tags_array)
|
||||
{
|
||||
string_free_split_shared (line_data->tags_array);
|
||||
|
@ -1120,6 +1126,9 @@ gui_line_free (struct t_gui_buffer *buffer, struct t_gui_line *line)
|
|||
{
|
||||
struct t_gui_line *ptr_line;
|
||||
|
||||
if (!buffer || !line)
|
||||
return;
|
||||
|
||||
/* first remove mixed line if it exists */
|
||||
if (buffer->mixed_lines)
|
||||
{
|
||||
|
|
|
@ -332,15 +332,16 @@ gui_window_tree_node_to_leaf (struct t_gui_window_tree *node,
|
|||
void
|
||||
gui_window_tree_free (struct t_gui_window_tree **tree)
|
||||
{
|
||||
if (*tree)
|
||||
{
|
||||
if ((*tree)->child1)
|
||||
gui_window_tree_free (&((*tree)->child1));
|
||||
if ((*tree)->child2)
|
||||
gui_window_tree_free (&((*tree)->child2));
|
||||
free (*tree);
|
||||
*tree = NULL;
|
||||
}
|
||||
if (!tree || !*tree)
|
||||
return;
|
||||
|
||||
if ((*tree)->child1)
|
||||
gui_window_tree_free (&((*tree)->child1));
|
||||
if ((*tree)->child2)
|
||||
gui_window_tree_free (&((*tree)->child2));
|
||||
|
||||
free (*tree);
|
||||
*tree = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -418,6 +419,9 @@ void
|
|||
gui_window_scroll_free (struct t_gui_window *window,
|
||||
struct t_gui_window_scroll *scroll)
|
||||
{
|
||||
if (!window || !scroll)
|
||||
return;
|
||||
|
||||
if (scroll->prev_scroll)
|
||||
(scroll->prev_scroll)->next_scroll = scroll->next_scroll;
|
||||
if (scroll->next_scroll)
|
||||
|
|
Loading…
Reference in New Issue