diff --git a/ChangeLog b/ChangeLog index b6bb7f0a12..852739c57b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2006-04-12 Matthias Clasen + * gtk/gtktreeviewcolumn.c (_gtk_tree_view_column_get_neighbor_sizes): + Reorganize to avoid a possible NULL pointer dereference. (Coverity) + * gtk/gtknotebook.c (gtk_notebook_page_allocate): Reorganize to avoid a possible NULL dereference. (Coverity) diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index b6bb7f0a12..852739c57b 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,5 +1,8 @@ 2006-04-12 Matthias Clasen + * gtk/gtktreeviewcolumn.c (_gtk_tree_view_column_get_neighbor_sizes): + Reorganize to avoid a possible NULL pointer dereference. (Coverity) + * gtk/gtknotebook.c (gtk_notebook_page_allocate): Reorganize to avoid a possible NULL dereference. (Coverity) diff --git a/gtk/gtktreeviewcolumn.c b/gtk/gtktreeviewcolumn.c index 32493d7f77..8313a264ef 100644 --- a/gtk/gtktreeviewcolumn.c +++ b/gtk/gtktreeviewcolumn.c @@ -3554,68 +3554,43 @@ _gtk_tree_view_column_get_neighbor_sizes (GtkTreeViewColumn *column, gint *right) { GList *list; - gint *rtl_left, *rtl_right; + GtkTreeViewColumnCellInfo *info; + gint l, r; + gboolean rtl; - if (gtk_widget_get_direction (GTK_WIDGET (column->tree_view)) == GTK_TEXT_DIR_RTL) + l = r = 0; + + list = gtk_tree_view_column_cell_first (column); + + while (list) { - rtl_left = right; - rtl_right = left; - } - else - { - rtl_left = left; - rtl_right = right; + info = (GtkTreeViewColumnCellInfo *)list->data; + + list = gtk_tree_view_column_cell_next (column, list); + + if (info->cell == cell) + break; + + if (info->cell->visible) + l += info->real_width; } - if (rtl_left) + while (list) { - *rtl_left = 0; - list = gtk_tree_view_column_cell_first (column); + info = (GtkTreeViewColumnCellInfo *)list->data; + + list = gtk_tree_view_column_cell_next (column, list); - for (; list; list = gtk_tree_view_column_cell_next (column, list)) - { - GtkTreeViewColumnCellInfo *info = - (GtkTreeViewColumnCellInfo *)list->data; - - if (info->cell == cell) - break; - - if (info->cell->visible) - *rtl_left += info->real_width; - } + if (info->cell->visible) + r += info->real_width; } - if (rtl_right) - { - GList *next; + rtl = (gtk_widget_get_direction (GTK_WIDGET (column->tree_view)) == GTK_TEXT_DIR_RTL); + if (left) + *left = rtl ? r : l; - *rtl_right = 0; - list = gtk_tree_view_column_cell_first (column); - - for (; list; list = gtk_tree_view_column_cell_next (column, list)) - { - GtkTreeViewColumnCellInfo *info = - (GtkTreeViewColumnCellInfo *)list->data; - - if (info->cell == cell) - break; - } - - /* skip cell */ - next = gtk_tree_view_column_cell_next (column, list); - if (list && next) - { - list = next; - for ( ; list; list = gtk_tree_view_column_cell_next (column, list)) - { - GtkTreeViewColumnCellInfo *info = - (GtkTreeViewColumnCellInfo *)list->data; - - if (info->cell->visible) - *rtl_right += info->real_width; - } - } - } + if (right) + *right = rtl ? l : r; } /**