aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@ximian.com>2001-10-17 07:27:58 +0800
committerChris Lahey <clahey@src.gnome.org>2001-10-17 07:27:58 +0800
commit7530d8bb8839302e1d7671d3b610c018ff8bc8ad (patch)
tree836b91b672277fae1699af98ab601b301565a679
parentef81fab34a91adba34609a5a4f3eb1d744880617 (diff)
downloadgsoc2013-evolution-7530d8bb8839302e1d7671d3b610c018ff8bc8ad.tar
gsoc2013-evolution-7530d8bb8839302e1d7671d3b610c018ff8bc8ad.tar.gz
gsoc2013-evolution-7530d8bb8839302e1d7671d3b610c018ff8bc8ad.tar.bz2
gsoc2013-evolution-7530d8bb8839302e1d7671d3b610c018ff8bc8ad.tar.lz
gsoc2013-evolution-7530d8bb8839302e1d7671d3b610c018ff8bc8ad.tar.xz
gsoc2013-evolution-7530d8bb8839302e1d7671d3b610c018ff8bc8ad.tar.zst
gsoc2013-evolution-7530d8bb8839302e1d7671d3b610c018ff8bc8ad.zip
Added bounds checking in a number of places. (etta_init): Initialize all
2001-10-16 Christopher James Lahey <clahey@ximian.com> * e-tree-table-adapter.c (find_next_node_maybe_deleted, find_first_child_node_maybe_deleted, find_next_node, find_first_child_node, find_row_num): Added bounds checking in a number of places. (etta_init): Initialize all the fields here. svn path=/trunk/; revision=13712
-rw-r--r--widgets/table/e-tree-table-adapter.c58
1 files changed, 41 insertions, 17 deletions
diff --git a/widgets/table/e-tree-table-adapter.c b/widgets/table/e-tree-table-adapter.c
index d22bbeba6b..2533b9a4da 100644
--- a/widgets/table/e-tree-table-adapter.c
+++ b/widgets/table/e-tree-table-adapter.c
@@ -158,7 +158,11 @@ find_next_node_maybe_deleted(ETreeTableAdapter *adapter, int row)
ETreePath path = adapter->priv->map_table[row];
if (path) {
ETreeTableAdapterNode *current = find_node (adapter, path);
- return row + (current ? current->num_visible_children : 0) + 1;
+
+ row += (current ? current->num_visible_children : 0) + 1;
+ if (row >= adapter->priv->n_map)
+ return -1;
+ return row;
} else
return -1;
}
@@ -169,9 +173,12 @@ find_first_child_node_maybe_deleted(ETreeTableAdapter *adapter, int row)
if (row != -1) {
ETreePath path = adapter->priv->map_table[row];
ETreeTableAdapterNode *current = find_node (adapter, path);
- if (current && current->expanded)
- return row + 1;
- else
+ if (current && current->expanded) {
+ row ++;
+ if (row >= adapter->priv->n_map)
+ return -1;
+ return row;
+ } else
return -1;
} else
return 0;
@@ -184,9 +191,12 @@ find_next_node(ETreeTableAdapter *adapter, int row)
if (path) {
ETreePath next_sibling = e_tree_model_node_get_next(adapter->priv->source, path);
ETreeTableAdapterNode *current = find_node (adapter, path);
- if (next_sibling)
- return row + (current ? current->num_visible_children : 0) + 1;
- else
+ if (next_sibling) {
+ row += (current ? current->num_visible_children : 0) + 1;
+ if (row >= adapter->priv->n_map)
+ return -1;
+ return row;
+ } else
return -1;
} else
return -1;
@@ -199,9 +209,12 @@ find_first_child_node(ETreeTableAdapter *adapter, int row)
ETreePath path = adapter->priv->map_table[row];
ETreePath first_child = e_tree_model_node_get_first_child(adapter->priv->source, path);
ETreeTableAdapterNode *current = find_node (adapter, path);
- if (first_child && current && current->expanded)
- return row + 1;
- else
+ if (first_child && current && current->expanded) {
+ row ++;
+ if (row >= adapter->priv->n_map)
+ return -1;
+ return row;
+ } else
return -1;
} else
return 0;
@@ -229,6 +242,8 @@ find_row_num(ETreeTableAdapter *etta, ETreePath path)
if (etta->priv->map_table == NULL)
return -1;
+ if (etta->priv->n_map == 0)
+ return -1;
if (path == NULL)
return -1;
@@ -574,16 +589,25 @@ etta_class_init (ETreeTableAdapterClass *klass)
static void
etta_init (ETreeTableAdapter *etta)
{
- etta->priv = g_new(ETreeTableAdapterPriv, 1);
+ etta->priv = g_new(ETreeTableAdapterPriv, 1);
+
+ etta->priv->source = NULL;
+
+ etta->priv->n_map = 0;
+ etta->priv->n_vals_allocated = 0;
+ etta->priv->map_table = NULL;
+ etta->priv->attributes = NULL;
- etta->priv->last_access = 0;
- etta->priv->map_table = NULL;
- etta->priv->n_map = 0;
- etta->priv->n_vals_allocated = 0;
+ etta->priv->root_visible = TRUE;
- etta->priv->root_visible = TRUE;
+ etta->priv->last_access = 0;
- etta->priv->attributes = NULL;
+ etta->priv->tree_model_pre_change_id = 0;
+ etta->priv->tree_model_node_changed_id = 0;
+ etta->priv->tree_model_node_data_changed_id = 0;
+ etta->priv->tree_model_node_col_changed_id = 0;
+ etta->priv->tree_model_node_inserted_id = 0;
+ etta->priv->tree_model_node_removed_id = 0;
}
E_MAKE_TYPE(e_tree_table_adapter, "ETreeTableAdapter", ETreeTableAdapter, etta_class_init, etta_init, PARENT_TYPE);