core: fix NULL pointer in free of bar window (closes #293); add extra checks on bar window pointers
This commit is contained in:
parent
6d1251415f
commit
ca5aa6695f
@ -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 max_length, max_length_screen;
|
||||||
int total_items, columns, lines;
|
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)
|
|| !bar_window->items_num_lines || !bar_window->items_refresh_needed)
|
||||||
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
snprintf (str_reinit_color, sizeof (str_reinit_color),
|
snprintf (str_reinit_color, sizeof (str_reinit_color),
|
||||||
"%c",
|
"%c",
|
||||||
@ -993,6 +996,9 @@ gui_bar_window_coords_add (struct t_gui_bar_window *bar_window,
|
|||||||
{
|
{
|
||||||
struct t_gui_bar_window_coords **coords2;
|
struct t_gui_bar_window_coords **coords2;
|
||||||
|
|
||||||
|
if (!bar_window)
|
||||||
|
return;
|
||||||
|
|
||||||
if (!bar_window->coords)
|
if (!bar_window->coords)
|
||||||
{
|
{
|
||||||
bar_window->coords_count = 1;
|
bar_window->coords_count = 1;
|
||||||
@ -1032,6 +1038,9 @@ gui_bar_window_coords_free (struct t_gui_bar_window *bar_window)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (!bar_window)
|
||||||
|
return;
|
||||||
|
|
||||||
if (bar_window->coords)
|
if (bar_window->coords)
|
||||||
{
|
{
|
||||||
for (i = 0; i < bar_window->coords_count; i++)
|
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;
|
struct t_gui_bar_window *pos_bar_window;
|
||||||
|
|
||||||
|
if (!bar_window || !window)
|
||||||
|
return;
|
||||||
|
|
||||||
if (window->bar_windows)
|
if (window->bar_windows)
|
||||||
{
|
{
|
||||||
pos_bar_window = gui_bar_window_find_pos (bar_window->bar, window);
|
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
|
int
|
||||||
gui_bar_window_get_current_size (struct t_gui_bar_window *bar_window)
|
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;
|
int new_size, max_size;
|
||||||
|
|
||||||
|
if (!bar_window)
|
||||||
|
return;
|
||||||
|
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
new_size = 1;
|
new_size = 1;
|
||||||
else
|
else
|
||||||
@ -1285,6 +1300,9 @@ void
|
|||||||
gui_bar_window_free (struct t_gui_bar_window *bar_window,
|
gui_bar_window_free (struct t_gui_bar_window *bar_window,
|
||||||
struct t_gui_window *window)
|
struct t_gui_window *window)
|
||||||
{
|
{
|
||||||
|
if (!bar_window)
|
||||||
|
return;
|
||||||
|
|
||||||
/* remove window bar from list */
|
/* remove window bar from list */
|
||||||
if (window)
|
if (window)
|
||||||
{
|
{
|
||||||
@ -1437,6 +1455,9 @@ gui_bar_window_scroll (struct t_gui_bar_window *bar_window,
|
|||||||
{
|
{
|
||||||
int old_scroll_x, old_scroll_y;
|
int old_scroll_x, old_scroll_y;
|
||||||
|
|
||||||
|
if (!bar_window)
|
||||||
|
return;
|
||||||
|
|
||||||
old_scroll_x = bar_window->scroll_x;
|
old_scroll_x = bar_window->scroll_x;
|
||||||
old_scroll_y = bar_window->scroll_y;
|
old_scroll_y = bar_window->scroll_y;
|
||||||
|
|
||||||
|
@ -863,10 +863,12 @@ gui_bar_config_change_hidden (void *data, struct t_config_option *option)
|
|||||||
{
|
{
|
||||||
if (CONFIG_BOOLEAN(ptr_bar->options[GUI_BAR_OPTION_HIDDEN]))
|
if (CONFIG_BOOLEAN(ptr_bar->options[GUI_BAR_OPTION_HIDDEN]))
|
||||||
{
|
{
|
||||||
|
if (ptr_bar->bar_window)
|
||||||
gui_bar_window_free (ptr_bar->bar_window, NULL);
|
gui_bar_window_free (ptr_bar->bar_window, NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (!ptr_bar->bar_window)
|
||||||
gui_bar_window_new (ptr_bar, NULL);
|
gui_bar_window_new (ptr_bar, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user