Fix of bug 173216 - Random signond crash found during google sign-in - glib client...
authorAurel Popirtac <ext-aurel.popirtac@nokia.com>
Fri, 11 Jun 2010 11:09:28 +0000 (14:09 +0300)
committerAurel Popirtac <ext-aurel.popirtac@nokia.com>
Fri, 11 Jun 2010 11:09:28 +0000 (14:09 +0300)
libsignon-glib/signon-identity.c

index 74af8dd18db080031630894a5c25237f633f34ca..52502864b4642c735264fabcd43466de5d2adb55 100644 (file)
@@ -544,6 +544,33 @@ SignonAuthSession *signon_identity_create_session(SignonIdentity *self,
     g_return_val_if_fail (priv != NULL, NULL);
 
     DEBUG ("%s %d", G_STRFUNC, __LINE__);
+    
+    if (method == NULL)
+    {
+        DEBUG ("NULL method as input. Aborting.");
+        *error = g_error_new (signon_error_quark(),
+                              SIGNON_ERROR_UNKNOWN,
+                              "NULL input method.");
+        return NULL;
+    }
+    
+    GSList *list = priv->sessions;
+    while (list)
+    {
+        SignonAuthSession *session = SIGNON_AUTH_SESSION (priv->sessions->data);
+        const gchar *sessionMethod = signon_auth_session_get_method (session);
+        if (g_strcmp0(sessionMethod, method) == 0) 
+        {
+            DEBUG ("Auth Session with method `%s`already created.", method);
+            *error = g_error_new (signon_error_quark(),
+                                  SIGNON_ERROR_METHOD_NOT_AVAILABLE,
+                                  "Authentication session for this method already requested.");
+            return NULL;
+        }
+
+        list = list->next;
+    }
+    *error = NULL;
 
     SignonAuthSession *session = signon_auth_session_new (priv->id,
                                                           method,