aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/misc
diff options
context:
space:
mode:
authorHans Petter Jansson <hpj@ximian.com>2004-06-23 03:12:13 +0800
committerHans Petter <hansp@src.gnome.org>2004-06-23 03:12:13 +0800
commitaee2630d0610468ced5ac66a8634807e27948aef (patch)
treead62b6814cb0f420e5a7c1f889f08737960d35c2 /widgets/misc
parentfe72753fe028ef628b38776829e9dd771064bb41 (diff)
downloadgsoc2013-evolution-aee2630d0610468ced5ac66a8634807e27948aef.tar
gsoc2013-evolution-aee2630d0610468ced5ac66a8634807e27948aef.tar.gz
gsoc2013-evolution-aee2630d0610468ced5ac66a8634807e27948aef.tar.bz2
gsoc2013-evolution-aee2630d0610468ced5ac66a8634807e27948aef.tar.lz
gsoc2013-evolution-aee2630d0610468ced5ac66a8634807e27948aef.tar.xz
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/misc')
-rw-r--r--widgets/misc/e-source-selector.c22
1 files changed, 17 insertions, 5 deletions
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);