diff options
author | Matthias Clasen <mclasen@redhat.com> | 2006-04-13 03:20:43 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2006-04-13 03:20:43 +0000 |
commit | 8557b5e2d7c76f81fbe81ba98d09390b541a1c5f (patch) | |
tree | 0823a52639699ce6c234e1e98cf204d53bdadcf9 /gtk/gtktreeviewcolumn.c | |
parent | 6afcd45024ef02798a4dcc078396a50f61636ddb (diff) | |
download | gtk+-8557b5e2d7c76f81fbe81ba98d09390b541a1c5f.tar.gz |
Reorganize to avoid a possible NULL pointer dereference. (Coverity)
2006-04-12 Matthias Clasen <mclasen@redhat.com>
* gtk/gtktreeviewcolumn.c (_gtk_tree_view_column_get_neighbor_sizes):
Reorganize to avoid a possible NULL pointer dereference. (Coverity)
Diffstat (limited to 'gtk/gtktreeviewcolumn.c')
-rw-r--r-- | gtk/gtktreeviewcolumn.c | 79 |
1 files changed, 27 insertions, 52 deletions
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) - { - rtl_left = right; - rtl_right = left; - } - else - { - rtl_left = left; - rtl_right = right; - } + l = r = 0; - if (rtl_left) - { - *rtl_left = 0; - list = gtk_tree_view_column_cell_first (column); + 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; + while (list) + { + info = (GtkTreeViewColumnCellInfo *)list->data; + + list = gtk_tree_view_column_cell_next (column, list); - if (info->cell->visible) - *rtl_left += info->real_width; - } + if (info->cell == cell) + break; + + if (info->cell->visible) + l += info->real_width; } - if (rtl_right) + while (list) { - GList *next; - - *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; + info = (GtkTreeViewColumnCellInfo *)list->data; + + list = gtk_tree_view_column_cell_next (column, list); - if (info->cell == cell) - break; - } + if (info->cell->visible) + r += info->real_width; + } - /* 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; + rtl = (gtk_widget_get_direction (GTK_WIDGET (column->tree_view)) == GTK_TEXT_DIR_RTL); + if (left) + *left = rtl ? r : l; - if (info->cell->visible) - *rtl_right += info->real_width; - } - } - } + if (right) + *right = rtl ? l : r; } /** |