diff options
author | Hans Petter Jansson <hpj@ximian.com> | 2004-06-23 03:12:13 +0800 |
---|---|---|
committer | Hans Petter <hansp@src.gnome.org> | 2004-06-23 03:12:13 +0800 |
commit | aee2630d0610468ced5ac66a8634807e27948aef (patch) | |
tree | ad62b6814cb0f420e5a7c1f889f08737960d35c2 /widgets | |
parent | fe72753fe028ef628b38776829e9dd771064bb41 (diff) | |
download | gsoc2013-evolution-aee2630d0610468ced5ac66a8634807e27948aef.tar.gz gsoc2013-evolution-aee2630d0610468ced5ac66a8634807e27948aef.tar.zst gsoc2013-evolution-aee2630d0610468ced5ac66a8634807e27948aef.zip |
Add preconditions. Make sure garbage or NULL data doesn't get used.
2004-06-22 Hans Petter Jansson <hpj@ximian.com>
* misc/e-source-selector.c (e_source_selector_peek_primary_selection):
Add preconditions. Make sure garbage or NULL data doesn't get used.
svn path=/trunk/; revision=26454
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/ChangeLog | 5 | ||||
-rw-r--r-- | widgets/misc/e-source-selector.c | 22 |
2 files changed, 22 insertions, 5 deletions
diff --git a/widgets/ChangeLog b/widgets/ChangeLog index 10dbdeb1da..994077622c 100644 --- a/widgets/ChangeLog +++ b/widgets/ChangeLog @@ -1,3 +1,8 @@ +2004-06-22 Hans Petter Jansson <hpj@ximian.com> + + * misc/e-source-selector.c (e_source_selector_peek_primary_selection): + Add preconditions. Make sure garbage or NULL data doesn't get used. + 2004-06-11 Larry Ewing <lewing@ximian.com> * misc/e-source-selector.c: make the source selector use a colock diff --git a/widgets/misc/e-source-selector.c b/widgets/misc/e-source-selector.c index 28da3314b4..1a0e0d1fbd 100644 --- a/widgets/misc/e-source-selector.c +++ b/widgets/misc/e-source-selector.c @@ -1001,21 +1001,33 @@ e_source_selector_source_is_selected (ESourceSelector *selector, ESource * e_source_selector_peek_primary_selection (ESourceSelector *selector) { - GtkTreeModel *model = GTK_TREE_MODEL (selector->priv->tree_store); + GtkTreeModel *model; GtkTreeIter iter; - void *data; + gboolean have_iter = FALSE; + void *data = NULL; + + g_return_val_if_fail (E_IS_SOURCE_SELECTOR (selector), NULL); + + model = GTK_TREE_MODEL (selector->priv->tree_store); if (selector->priv->saved_primary_selection) { GtkTreePath *child_path; child_path = gtk_tree_row_reference_get_path (selector->priv->saved_primary_selection); - gtk_tree_model_get_iter (GTK_TREE_MODEL (selector->priv->tree_store), &iter, child_path); + if (child_path) { + if (gtk_tree_model_get_iter (GTK_TREE_MODEL (selector->priv->tree_store), &iter, child_path)) + have_iter = TRUE; + gtk_tree_path_free (child_path); + } + } - gtk_tree_path_free (child_path); - } else if (! gtk_tree_selection_get_selected (gtk_tree_view_get_selection (GTK_TREE_VIEW (selector)), NULL, &iter)) + if (!have_iter && ! gtk_tree_selection_get_selected (gtk_tree_view_get_selection (GTK_TREE_VIEW (selector)), NULL, &iter)) return NULL; gtk_tree_model_get (model, &iter, 0, &data, -1); + if (!data) + return NULL; + if (! E_IS_SOURCE (data)) { g_object_unref (data); |