diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2024-04-25 00:19:31 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2024-04-26 07:37:22 +0200 |
commit | 3eed74a75c86758c519cfba60a6ba83dcb1eee1b (patch) | |
tree | 2b5931050d4973c70a4b5bbd9325120a6b5a58b2 | |
parent | e73bff95fa4bcc0902b65263bd47ec8bdc0c1128 (diff) | |
download | weechat-3eed74a75c86758c519cfba60a6ba83dcb1eee1b.zip |
plugins: remove check of NULL pointers before calling weechat_arraylist_free() (issue #865)
-rw-r--r-- | src/plugins/buflist/buflist-bar-item.c | 3 | ||||
-rw-r--r-- | src/plugins/fset/fset-command.c | 3 | ||||
-rw-r--r-- | src/plugins/irc/irc-ctcp.c | 3 | ||||
-rw-r--r-- | src/plugins/logger/logger-backlog.c | 3 | ||||
-rw-r--r-- | src/plugins/logger/logger-tail.c | 3 | ||||
-rw-r--r-- | tests/unit/core/test-core-arraylist.cpp | 3 |
6 files changed, 8 insertions, 10 deletions
diff --git a/src/plugins/buflist/buflist-bar-item.c b/src/plugins/buflist/buflist-bar-item.c index ac3fbe062..dcfa55503 100644 --- a/src/plugins/buflist/buflist-bar-item.c +++ b/src/plugins/buflist/buflist-bar-item.c @@ -372,8 +372,7 @@ buflist_bar_item_buflist_cb (const void *pointer, void *data, snprintf (str_format_number_empty, sizeof (str_format_number_empty), "%%-%ds", length_max_number); - if (buflist_list_buffers[item_index]) - weechat_arraylist_free (buflist_list_buffers[item_index]); + weechat_arraylist_free (buflist_list_buffers[item_index]); buflist_list_buffers[item_index] = weechat_arraylist_new ( 16, 0, 1, NULL, NULL, NULL, NULL); diff --git a/src/plugins/fset/fset-command.c b/src/plugins/fset/fset-command.c index ec0f5e25d..7e60995ac 100644 --- a/src/plugins/fset/fset-command.c +++ b/src/plugins/fset/fset-command.c @@ -567,8 +567,7 @@ fset_command_run_set_cb (const void *pointer, void *data, /* check condition to trigger the fset buffer */ if (condition_ok) { - if (old_options) - weechat_arraylist_free (old_options); + weechat_arraylist_free (old_options); free (old_max_length); free (old_filter); diff --git a/src/plugins/irc/irc-ctcp.c b/src/plugins/irc/irc-ctcp.c index 619a16f1e..a34f28c57 100644 --- a/src/plugins/irc/irc-ctcp.c +++ b/src/plugins/irc/irc-ctcp.c @@ -495,8 +495,7 @@ end: free (dup_ctcp); free (dup_ctcp_upper); free (dup_args); - if (list_messages) - weechat_arraylist_free (list_messages); + weechat_arraylist_free (list_messages); } /* diff --git a/src/plugins/logger/logger-backlog.c b/src/plugins/logger/logger-backlog.c index 6f211b382..1bb015460 100644 --- a/src/plugins/logger/logger-backlog.c +++ b/src/plugins/logger/logger-backlog.c @@ -243,8 +243,7 @@ logger_backlog_group_messages (struct t_arraylist *lines) error: free (message); - if (messages) - weechat_arraylist_free (messages); + weechat_arraylist_free (messages); return NULL; } diff --git a/src/plugins/logger/logger-tail.c b/src/plugins/logger/logger-tail.c index fec93873e..9263b5e7f 100644 --- a/src/plugins/logger/logger-tail.c +++ b/src/plugins/logger/logger-tail.c @@ -233,8 +233,7 @@ logger_tail_file (const char *filename, int lines) error: free (part_of_line); - if (list_lines) - weechat_arraylist_free (list_lines); + weechat_arraylist_free (list_lines); if (fd >= 0) close (fd); return NULL; diff --git a/tests/unit/core/test-core-arraylist.cpp b/tests/unit/core/test-core-arraylist.cpp index dd6d3b369..2f8d1ceb2 100644 --- a/tests/unit/core/test-core-arraylist.cpp +++ b/tests/unit/core/test-core-arraylist.cpp @@ -481,6 +481,9 @@ TEST(CoreArraylist, New) { int initial_size, sorted, allow_duplicates; + /* free arraylist with NULL pointer */ + arraylist_free (NULL); + /* * in order to create an arraylist, initial_size must be >= 0 and a * comparison callback must be given |