Fixes several potential infinite loops with corrupted account data
[modest] / src / modest-account-mgr.c
index f77e247..c3e12dc 100644 (file)
@@ -768,9 +768,11 @@ modest_account_mgr_account_names (ModestAccountMgr * self, gboolean only_enabled
        /* Unescape the keys to get the account names: */
        GSList *iter = accounts;
        while (iter) {
-               if (!(iter->data))
+               if (!(iter->data)) {
+                       iter = iter->next;
                        continue;
-                       
+               }
+
                const gchar* account_name_key = (const gchar*)iter->data;
                gchar* unescaped_name = account_name_key ? 
                        modest_conf_key_unescape (account_name_key) 
@@ -1132,6 +1134,7 @@ modest_account_mgr_account_with_display_name_exists  (ModestAccountMgr *self,
                ModestAccountSettings *settings = modest_account_mgr_load_account_settings (self, account_name);
                if (!settings) {
                        g_printerr ("modest: failed to get account data for %s\n", account_name);
+                       cursor = cursor->next;
                        continue;
                }
 
@@ -1210,6 +1213,7 @@ modest_account_mgr_check_already_configured_account  (ModestAccountMgr *self,
                from_mgr_settings = modest_account_mgr_load_account_settings (self, account_name);
                if (!settings) {
                        g_printerr ("modest: failed to get account data for %s\n", account_name);
+                       cursor = cursor->next;
                        continue;
                }
 
@@ -1650,3 +1654,28 @@ modest_account_mgr_set_display_name (ModestAccountMgr *self,
        if (notify)
                g_signal_emit (self, signals[DISPLAY_NAME_CHANGED_SIGNAL], 0, account_name);
 }
+
+gboolean 
+modest_account_mgr_singleton_protocol_exists (ModestAccountMgr *mgr,
+                                             ModestProtocolType protocol_type)
+{
+       GSList *account_names, *node;
+       gboolean found = FALSE;
+
+       g_return_val_if_fail (MODEST_IS_ACCOUNT_MGR (mgr), FALSE);
+       account_names = modest_account_mgr_account_names (mgr, TRUE);
+
+       for (node = account_names; node != NULL; node = g_slist_next (node)) {
+               ModestProtocolType current_protocol;
+
+               current_protocol = modest_account_mgr_get_store_protocol (mgr, (gchar *) node->data);
+               if (current_protocol == protocol_type) {
+                       found = TRUE;
+                       break;
+               }
+       }
+
+       modest_account_mgr_free_account_names (account_names);
+
+       return found;
+}