summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2015-01-03 19:18:09 +0100
committerSébastien Helleu <flashcode@flashtux.org>2015-01-03 19:18:09 +0100
commitca5aa6695f13637ec23f471408e82ce45cc60710 (patch)
treed67f70f5e18ae2f67ab3135878b4f436d1753571 /src/gui
parent6d1251415fc1d14018dd8280f7521bd7619ccfbf (diff)
downloadweechat-ca5aa6695f13637ec23f471408e82ce45cc60710.zip
core: fix NULL pointer in free of bar window (closes #293); add extra checks on bar window pointers
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/gui-bar-window.c25
-rw-r--r--src/gui/gui-bar.c6
2 files changed, 27 insertions, 4 deletions
diff --git a/src/gui/gui-bar-window.c b/src/gui/gui-bar-window.c
index 15b8bda7a..546c5aedc 100644
--- a/src/gui/gui-bar-window.c
+++ b/src/gui/gui-bar-window.c
@@ -686,9 +686,12 @@ gui_bar_window_content_get_with_filling (struct t_gui_bar_window *bar_window,
int max_length, max_length_screen;
int total_items, columns, lines;
- if (!bar_window->items_subcount || !bar_window->items_content
+ if (!bar_window
+ || !bar_window->items_subcount || !bar_window->items_content
|| !bar_window->items_num_lines || !bar_window->items_refresh_needed)
+ {
return NULL;
+ }
snprintf (str_reinit_color, sizeof (str_reinit_color),
"%c",
@@ -993,6 +996,9 @@ gui_bar_window_coords_add (struct t_gui_bar_window *bar_window,
{
struct t_gui_bar_window_coords **coords2;
+ if (!bar_window)
+ return;
+
if (!bar_window->coords)
{
bar_window->coords_count = 1;
@@ -1032,6 +1038,9 @@ gui_bar_window_coords_free (struct t_gui_bar_window *bar_window)
{
int i;
+ if (!bar_window)
+ return;
+
if (bar_window->coords)
{
for (i = 0; i < bar_window->coords_count; i++)
@@ -1055,6 +1064,9 @@ gui_bar_window_insert (struct t_gui_bar_window *bar_window,
{
struct t_gui_bar_window *pos_bar_window;
+ if (!bar_window || !window)
+ return;
+
if (window->bar_windows)
{
pos_bar_window = gui_bar_window_find_pos (bar_window->bar, window);
@@ -1164,7 +1176,7 @@ gui_bar_window_new (struct t_gui_bar *bar, struct t_gui_window *window)
int
gui_bar_window_get_current_size (struct t_gui_bar_window *bar_window)
{
- return bar_window->current_size;
+ return (bar_window) ? bar_window->current_size : 0;
}
/*
@@ -1243,6 +1255,9 @@ gui_bar_window_set_current_size (struct t_gui_bar_window *bar_window,
{
int new_size, max_size;
+ if (!bar_window)
+ return;
+
if (size == 0)
new_size = 1;
else
@@ -1285,6 +1300,9 @@ void
gui_bar_window_free (struct t_gui_bar_window *bar_window,
struct t_gui_window *window)
{
+ if (!bar_window)
+ return;
+
/* remove window bar from list */
if (window)
{
@@ -1437,6 +1455,9 @@ gui_bar_window_scroll (struct t_gui_bar_window *bar_window,
{
int old_scroll_x, old_scroll_y;
+ if (!bar_window)
+ return;
+
old_scroll_x = bar_window->scroll_x;
old_scroll_y = bar_window->scroll_y;
diff --git a/src/gui/gui-bar.c b/src/gui/gui-bar.c
index 480758d90..121041422 100644
--- a/src/gui/gui-bar.c
+++ b/src/gui/gui-bar.c
@@ -863,11 +863,13 @@ gui_bar_config_change_hidden (void *data, struct t_config_option *option)
{
if (CONFIG_BOOLEAN(ptr_bar->options[GUI_BAR_OPTION_HIDDEN]))
{
- gui_bar_window_free (ptr_bar->bar_window, NULL);
+ if (ptr_bar->bar_window)
+ gui_bar_window_free (ptr_bar->bar_window, NULL);
}
else
{
- gui_bar_window_new (ptr_bar, NULL);
+ if (!ptr_bar->bar_window)
+ gui_bar_window_new (ptr_bar, NULL);
}
}
else