Fixes NB#132390, added a couple of extra checks to prevent invalid dereferences
[modest] / src / hildon2 / modest-account-view-window.c
index 5253bcc..5f3eeb0 100644 (file)
@@ -140,20 +140,20 @@ on_account_settings_dialog_response (GtkDialog *dialog,
        store_account = modest_tny_account_store_get_server_account (modest_runtime_get_account_store (),
                                                                     account_name,
                                                                     TNY_ACCOUNT_TYPE_STORE);
-       
-       /* Reconnect the store account, no need to reconnect the
-          transport account because it will connect when needed */
-       if (tny_account_get_connection_status (store_account) == 
-           TNY_CONNECTION_STATUS_DISCONNECTED)
-               tny_camel_account_set_online (TNY_CAMEL_ACCOUNT (store_account),
-                                             TRUE, NULL, NULL);
-
+        if (store_account) {
+               /* Reconnect the store account, no need to reconnect the
+                  transport account because it will connect when needed */
+               if (tny_account_get_connection_status (store_account) ==
+                   TNY_CONNECTION_STATUS_DISCONNECTED)
+                       tny_camel_account_set_online (TNY_CAMEL_ACCOUNT (store_account),
+                                                     TRUE, NULL, NULL);
+               g_object_unref (store_account);
+       }
        /* Disconnect this handler */
        g_signal_handlers_disconnect_by_func (dialog, on_account_settings_dialog_response, user_data);
 
        /* Free */
        g_free (account_name);
-       g_object_unref (store_account);
 }
 
 static void