summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2024-04-25 19:26:02 +0200
committerSébastien Helleu <flashcode@flashtux.org>2024-04-26 20:59:44 +0200
commit61ff0b858722f30b1da9107b205642cf193a2dd3 (patch)
treed695ce7c3091112e54dd5994c85a90686bd1fa0b
parent561dd92d8eba49ed2ae16fc4a0a1fb6ff349758b (diff)
downloadweechat-61ff0b858722f30b1da9107b205642cf193a2dd3.zip
core: remove check of NULL pointers before calling config_file_option_free() (issue #865)
-rw-r--r--src/core/core-proxy.c18
-rw-r--r--src/gui/gui-bar-item-custom.c9
-rw-r--r--src/gui/gui-bar.c45
-rw-r--r--src/gui/gui-key.c6
4 files changed, 26 insertions, 52 deletions
diff --git a/src/core/core-proxy.c b/src/core/core-proxy.c
index 1ad70eddd..edd0c6b4c 100644
--- a/src/core/core-proxy.c
+++ b/src/core/core-proxy.c
@@ -456,18 +456,12 @@ proxy_new (const char *name, const char *type, const char *ipv6,
option_username, option_password);
if (!new_proxy)
{
- if (option_type)
- config_file_option_free (option_type, 0);
- if (option_ipv6)
- config_file_option_free (option_ipv6, 0);
- if (option_address)
- config_file_option_free (option_address, 0);
- if (option_port)
- config_file_option_free (option_port, 0);
- if (option_username)
- config_file_option_free (option_username, 0);
- if (option_password)
- config_file_option_free (option_password, 0);
+ config_file_option_free (option_type, 0);
+ config_file_option_free (option_ipv6, 0);
+ config_file_option_free (option_address, 0);
+ config_file_option_free (option_port, 0);
+ config_file_option_free (option_username, 0);
+ config_file_option_free (option_password, 0);
}
return new_proxy;
diff --git a/src/gui/gui-bar-item-custom.c b/src/gui/gui-bar-item-custom.c
index 70a6d91a7..fac56ab40 100644
--- a/src/gui/gui-bar-item-custom.c
+++ b/src/gui/gui-bar-item-custom.c
@@ -480,10 +480,8 @@ error:
}
else
{
- if (option_conditions)
- config_file_option_free (option_conditions, 0);
- if (option_content)
- config_file_option_free (option_content, 0);
+ config_file_option_free (option_conditions, 0);
+ config_file_option_free (option_content, 0);
}
return NULL;
}
@@ -612,8 +610,7 @@ gui_bar_item_custom_free_data (struct t_gui_bar_item_custom *item)
free (item->name);
for (i = 0; i < GUI_BAR_ITEM_CUSTOM_NUM_OPTIONS; i++)
{
- if (item->options[i])
- config_file_option_free (item->options[i], 1);
+ config_file_option_free (item->options[i], 1);
}
}
diff --git a/src/gui/gui-bar.c b/src/gui/gui-bar.c
index f8104ca9a..03c03932b 100644
--- a/src/gui/gui-bar.c
+++ b/src/gui/gui-bar.c
@@ -1776,34 +1776,20 @@ gui_bar_new (const char *name, const char *hidden, const char *priority,
option_items);
if (!ptr_bar)
{
- if (option_hidden)
- config_file_option_free (option_hidden, 0);
- if (option_priority)
- config_file_option_free (option_priority, 0);
- if (option_type)
- config_file_option_free (option_type, 0);
- if (option_conditions)
- config_file_option_free (option_conditions, 0);
- if (option_position)
- config_file_option_free (option_position, 0);
- if (option_filling_top_bottom)
- config_file_option_free (option_filling_top_bottom, 0);
- if (option_filling_left_right)
- config_file_option_free (option_filling_left_right, 0);
- if (option_size)
- config_file_option_free (option_size, 0);
- if (option_size_max)
- config_file_option_free (option_size_max, 0);
- if (option_color_fg)
- config_file_option_free (option_color_fg, 0);
- if (option_color_delim)
- config_file_option_free (option_color_delim, 0);
- if (option_color_bg)
- config_file_option_free (option_color_bg, 0);
- if (option_separator)
- config_file_option_free (option_separator, 0);
- if (option_items)
- config_file_option_free (option_items, 0);
+ config_file_option_free (option_hidden, 0);
+ config_file_option_free (option_priority, 0);
+ config_file_option_free (option_type, 0);
+ config_file_option_free (option_conditions, 0);
+ config_file_option_free (option_position, 0);
+ config_file_option_free (option_filling_top_bottom, 0);
+ config_file_option_free (option_filling_left_right, 0);
+ config_file_option_free (option_size, 0);
+ config_file_option_free (option_size_max, 0);
+ config_file_option_free (option_color_fg, 0);
+ config_file_option_free (option_color_delim, 0);
+ config_file_option_free (option_color_bg, 0);
+ config_file_option_free (option_separator, 0);
+ config_file_option_free (option_items, 0);
}
}
@@ -2215,8 +2201,7 @@ gui_bar_free (struct t_gui_bar *bar)
free (bar->name);
for (i = 0; i < GUI_BAR_NUM_OPTIONS; i++)
{
- if (bar->options[i])
- config_file_option_free (bar->options[i], 1);
+ config_file_option_free (bar->options[i], 1);
}
gui_bar_free_items_arrays (bar);
diff --git a/src/gui/gui-key.c b/src/gui/gui-key.c
index a38b6a522..ab776f2c5 100644
--- a/src/gui/gui-key.c
+++ b/src/gui/gui-key.c
@@ -1564,8 +1564,7 @@ error:
gui_key_context_string[context]);
}
free (key_fixed);
- if (ptr_option)
- config_file_option_free (ptr_option, 0);
+ config_file_option_free (ptr_option, 0);
return NULL;
}
@@ -2625,8 +2624,7 @@ gui_key_free (int context,
weechat_config_file,
weechat_config_section_key[context],
key->key);
- if (ptr_option)
- config_file_option_free (ptr_option, 1);
+ config_file_option_free (ptr_option, 1);
}
/* free memory */