summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2017-03-25 14:01:50 +0100
committerSébastien Helleu <flashcode@flashtux.org>2017-03-25 14:01:50 +0100
commit0d059add9aa4debf47e58af1ef6a6a5e72e3a1ac (patch)
tree356cf8fcaca39f978fb525f7c93a324e5391aafb /src/gui
parenteebb0547e2f2431efaf1adce2a39dd4f5fc8909f (diff)
downloadweechat-0d059add9aa4debf47e58af1ef6a6a5e72e3a1ac.zip
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_free
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/curses/gui-curses-window.c3
-rw-r--r--src/gui/gui-color.c12
-rw-r--r--src/gui/gui-completion.c4
-rw-r--r--src/gui/gui-filter.c3
-rw-r--r--src/gui/gui-history.c3
-rw-r--r--src/gui/gui-hotlist.c3
-rw-r--r--src/gui/gui-key.c3
-rw-r--r--src/gui/gui-line.c9
-rw-r--r--src/gui/gui-window.c22
9 files changed, 47 insertions, 15 deletions
diff --git a/src/gui/curses/gui-curses-window.c b/src/gui/curses/gui-curses-window.c
index 05bd4e407..bda0b7e10 100644
--- a/src/gui/curses/gui-curses-window.c
+++ b/src/gui/curses/gui-curses-window.c
@@ -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);
diff --git a/src/gui/gui-color.c b/src/gui/gui-color.c
index 747fb840e..fcfb2a9bd 100644
--- a/src/gui/gui-color.c
+++ b/src/gui/gui-color.c
@@ -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);
}
/*
diff --git a/src/gui/gui-completion.c b/src/gui/gui-completion.c
index 9b6a12242..d5ece75fe 100644
--- a/src/gui/gui-completion.c
+++ b/src/gui/gui-completion.c
@@ -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);
}
diff --git a/src/gui/gui-filter.c b/src/gui/gui-filter.c
index 3b50f1922..e32f2be4a 100644
--- a/src/gui/gui-filter.c
+++ b/src/gui/gui-filter.c
@@ -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);
diff --git a/src/gui/gui-history.c b/src/gui/gui-history.c
index 8fbf4583a..2eaaf68d8 100644
--- a/src/gui/gui-history.c
+++ b/src/gui/gui-history.c
@@ -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;
diff --git a/src/gui/gui-hotlist.c b/src/gui/gui-hotlist.c
index c7cc1700d..9bbcf65e0 100644
--- a/src/gui/gui-hotlist.c
+++ b/src/gui/gui-hotlist.c
@@ -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;
diff --git a/src/gui/gui-key.c b/src/gui/gui-key.c
index 8da3bb666..e7255fb96 100644
--- a/src/gui/gui-key.c
+++ b/src/gui/gui-key.c
@@ -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);
diff --git a/src/gui/gui-line.c b/src/gui/gui-line.c
index 70296d0c7..63cfa6523 100644
--- a/src/gui/gui-line.c
+++ b/src/gui/gui-line.c
@@ -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)
{
diff --git a/src/gui/gui-window.c b/src/gui/gui-window.c
index 5713125b1..f3aaafc31 100644
--- a/src/gui/gui-window.c
+++ b/src/gui/gui-window.c
@@ -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)