Index: misc/e-search-bar.c
===================================================================
--- misc/e-search-bar.c	(revision 34020)
+++ misc/e-search-bar.c	(working copy)
@@ -1559,17 +1559,23 @@
 void e_search_bar_scope_enable (ESearchBar *esb, int did, gboolean state)
 {
 	GtkWidget *widget=NULL;
-	GList *l = GTK_MENU_SHELL (esb->scopeoption_menu)->children;
-	int row = -1, i = 0, id;
+	GList *l ;
+	int id;
+	gpointer *pointer;
 
+	g_return_val_if_fail (esb != NULL, NULL);
+	g_return_val_if_fail (E_IS_SEARCH_BAR (esb), NULL);
+
+	l = GTK_MENU_SHELL (esb->scopeoption_menu)->children;
 	while (l) {
-		id = GPOINTER_TO_INT (g_object_get_data (l->data, "EsbItemId"));
-		if (id == did) {
-			row = i;
-			widget = l->data;
-			break;
+		pointer = g_object_get_data (l->data, "EsbItemId");
+		if (pointer) {
+			id = GPOINTER_TO_INT (pointer);
+			if (id == did) {
+				widget = l->data;
+				break;
+			}
 		}
-		i++;
 		l = l->next;
 	}
 
