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)
This commit is contained in:
Matthias Clasen 2006-04-13 03:20:43 +00:00 committed by Matthias Clasen
parent 6afcd45024
commit 8557b5e2d7
3 changed files with 34 additions and 53 deletions

View File

@ -1,5 +1,8 @@
2006-04-12 Matthias Clasen <mclasen@redhat.com> 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)
* gtk/gtknotebook.c (gtk_notebook_page_allocate): Reorganize * gtk/gtknotebook.c (gtk_notebook_page_allocate): Reorganize
to avoid a possible NULL dereference. (Coverity) to avoid a possible NULL dereference. (Coverity)

View File

@ -1,5 +1,8 @@
2006-04-12 Matthias Clasen <mclasen@redhat.com> 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)
* gtk/gtknotebook.c (gtk_notebook_page_allocate): Reorganize * gtk/gtknotebook.c (gtk_notebook_page_allocate): Reorganize
to avoid a possible NULL dereference. (Coverity) to avoid a possible NULL dereference. (Coverity)

View File

@ -3554,68 +3554,43 @@ _gtk_tree_view_column_get_neighbor_sizes (GtkTreeViewColumn *column,
gint *right) gint *right)
{ {
GList *list; 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;
{
rtl_left = right;
rtl_right = left;
}
else
{
rtl_left = left;
rtl_right = right;
}
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)) while (list)
{ {
GtkTreeViewColumnCellInfo *info = info = (GtkTreeViewColumnCellInfo *)list->data;
(GtkTreeViewColumnCellInfo *)list->data;
list = gtk_tree_view_column_cell_next (column, list);
if (info->cell == cell) if (info->cell == cell)
break; break;
if (info->cell->visible) if (info->cell->visible)
*rtl_left += info->real_width; l += info->real_width;
}
} }
if (rtl_right) while (list)
{ {
GList *next; info = (GtkTreeViewColumnCellInfo *)list->data;
*rtl_right = 0; list = gtk_tree_view_column_cell_next (column, list);
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) if (info->cell->visible)
*rtl_right += info->real_width; r += info->real_width;
}
}
} }
rtl = (gtk_widget_get_direction (GTK_WIDGET (column->tree_view)) == GTK_TEXT_DIR_RTL);
if (left)
*left = rtl ? r : l;
if (right)
*right = rtl ? l : r;
} }
/** /**