summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2024-04-24 23:34:00 +0200
committerSébastien Helleu <flashcode@flashtux.org>2024-04-25 20:59:24 +0200
commit128d2a4e12bd9423f40f011060db0e9c5d8bc6bd (patch)
treec0c8c2d1943dbaeb1d7f60e175f0f104c5654a4f /src/plugins
parent846c7855312f0fc32e94316055834fbe68792c5b (diff)
downloadweechat-128d2a4e12bd9423f40f011060db0e9c5d8bc6bd.zip
logger: remove check of NULL pointers before calling free() (issue #865)
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/logger/logger-backlog.c6
-rw-r--r--src/plugins/logger/logger-buffer.c15
-rw-r--r--src/plugins/logger/logger-tail.c3
-rw-r--r--src/plugins/logger/logger.c36
4 files changed, 20 insertions, 40 deletions
diff --git a/src/plugins/logger/logger-backlog.c b/src/plugins/logger/logger-backlog.c
index 13b652e41..6f211b382 100644
--- a/src/plugins/logger/logger-backlog.c
+++ b/src/plugins/logger/logger-backlog.c
@@ -100,8 +100,7 @@ logger_backlog_display_line (struct t_gui_buffer *buffer, const char *line)
charset = weechat_info_get ("charset_terminal", "");
message2 = (charset) ?
weechat_iconv_to_internal (charset, message) : strdup (message);
- if (charset)
- free (charset);
+ free (charset);
if (message2)
{
pos_tab = strchr (message2, '\t');
@@ -243,8 +242,7 @@ logger_backlog_group_messages (struct t_arraylist *lines)
return messages;
error:
- if (message)
- free (message);
+ free (message);
if (messages)
weechat_arraylist_free (messages);
return NULL;
diff --git a/src/plugins/logger/logger-buffer.c b/src/plugins/logger/logger-buffer.c
index fe42c524a..d4911cb01 100644
--- a/src/plugins/logger/logger-buffer.c
+++ b/src/plugins/logger/logger-buffer.c
@@ -325,10 +325,8 @@ logger_buffer_create_log_file (struct t_logger_buffer *logger_buffer)
weechat_iconv_from_internal (charset, buf_beginning) : NULL;
fprintf (logger_buffer->log_file,
"%s\n", (message) ? message : buf_beginning);
- if (charset)
- free (charset);
- if (message)
- free (message);
+ free (charset);
+ free (message);
logger_buffer->flush_needed = 1;
}
logger_buffer->write_start_info_line = 0;
@@ -635,10 +633,8 @@ logger_buffer_write_line (struct t_logger_buffer *logger_buffer,
weechat_iconv_from_internal (charset, vbuffer) : NULL;
fprintf (logger_buffer->log_file,
"%s\n", (message) ? message : vbuffer);
- if (charset)
- free (charset);
- if (message)
- free (message);
+ free (charset);
+ free (message);
logger_buffer->flush_needed = 1;
if (!logger_hook_timer)
{
@@ -878,8 +874,7 @@ logger_buffer_free (struct t_logger_buffer *logger_buffer)
(logger_buffer->next_buffer)->prev_buffer = logger_buffer->prev_buffer;
/* free data */
- if (logger_buffer->log_filename)
- free (logger_buffer->log_filename);
+ free (logger_buffer->log_filename);
if (logger_buffer->log_file)
fclose (logger_buffer->log_file);
diff --git a/src/plugins/logger/logger-tail.c b/src/plugins/logger/logger-tail.c
index f075c3801..fec93873e 100644
--- a/src/plugins/logger/logger-tail.c
+++ b/src/plugins/logger/logger-tail.c
@@ -232,8 +232,7 @@ logger_tail_file (const char *filename, int lines)
return list_lines;
error:
- if (part_of_line)
- free (part_of_line);
+ free (part_of_line);
if (list_lines)
weechat_arraylist_free (list_lines);
if (fd >= 0)
diff --git a/src/plugins/logger/logger.c b/src/plugins/logger/logger.c
index 59acd2708..abecb6aa9 100644
--- a/src/plugins/logger/logger.c
+++ b/src/plugins/logger/logger.c
@@ -95,8 +95,7 @@ logger_check_conditions (struct t_gui_buffer *buffer, const char *conditions)
result = weechat_string_eval_expression (conditions,
pointers, NULL, options);
condition_ok = (result && (strcmp (result, "1") == 0));
- if (result)
- free (result);
+ free (result);
if (pointers)
weechat_hashtable_free (pointers);
@@ -162,8 +161,7 @@ logger_get_file_path ()
}
end:
- if (path)
- free (path);
+ free (path);
return path2;
}
@@ -434,18 +432,12 @@ logger_get_mask_expanded (struct t_gui_buffer *buffer, const char *mask)
end:
free (dir_separator);
- if (mask2)
- free (mask2);
- if (mask3)
- free (mask3);
- if (mask4)
- free (mask4);
- if (mask5)
- free (mask5);
- if (mask6)
- free (mask6);
- if (mask7)
- free (mask7);
+ free (mask2);
+ free (mask3);
+ free (mask4);
+ free (mask5);
+ free (mask6);
+ free (mask7);
return mask8;
}
@@ -507,10 +499,8 @@ logger_get_filename (struct t_gui_buffer *buffer)
end:
free (dir_separator);
- if (mask_expanded)
- free (mask_expanded);
- if (file_path)
- free (file_path);
+ free (mask_expanded);
+ free (file_path);
return res;
}
@@ -758,10 +748,8 @@ logger_print_cb (const void *pointer, void *data,
(color_lines) ? "\x1B[0m" : "",
ptr_message);
- if (prefix_ansi)
- free (prefix_ansi);
- if (message_ansi)
- free (message_ansi);
+ free (prefix_ansi);
+ free (message_ansi);
}
return WEECHAT_RC_OK;