Bug 1330955 - Stop crash in CMapiImp::Login(). r=rkent
authorJorg K <jorgk@jorgk.com>
Fri, 20 Jan 2017 08:43:00 +0100
changeset 21030 c3771425de0e070de6d5a5f2e6c62e8116f92379
parent 21029 9cb95ca4c3f7cbd473e78addb8e3607af6af8386
child 21031 48282013040ad39e8e7736103fd52031449a101b
push id12766
push usermozilla@jorgk.com
push dateFri, 20 Jan 2017 22:19:57 +0000
treeherdercomm-central@c3771425de0e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrkent
bugs1330955
Bug 1330955 - Stop crash in CMapiImp::Login(). r=rkent
mailnews/mapi/mapihook/src/msgMapiImp.cpp
--- a/mailnews/mapi/mapihook/src/msgMapiImp.cpp
+++ b/mailnews/mapi/mapihook/src/msgMapiImp.cpp
@@ -149,22 +149,23 @@ STDMETHODIMP CMapiImp::Login(unsigned lo
     {
       // get default account
       nsresult rv;
       nsCOMPtr <nsIMsgAccountManager> accountManager = 
         do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv); 
       NS_ENSURE_SUCCESS(rv,MAPI_E_LOGIN_FAILURE);
       nsCOMPtr <nsIMsgAccount> account;
       nsCOMPtr <nsIMsgIdentity> identity;
-       rv = accountManager->GetDefaultAccount(getter_AddRefs(account));
+      rv = accountManager->GetDefaultAccount(getter_AddRefs(account));
+      NS_ENSURE_SUCCESS(rv,MAPI_E_LOGIN_FAILURE);
+      rv = account->GetDefaultIdentity(getter_AddRefs(identity));
       NS_ENSURE_SUCCESS(rv,MAPI_E_LOGIN_FAILURE);
-      account->GetDefaultIdentity(getter_AddRefs(identity));
-      NS_ENSURE_SUCCESS(rv,MAPI_E_LOGIN_FAILURE);
+      if (!identity)
+        return MAPI_E_LOGIN_FAILURE;
       identity->GetKey(id_key);
-
     }
 
     // finally register(create) the session.
     uint32_t nSession_Id;
     int16_t nResult = 0;
 
     nsMAPIConfiguration *pConfig = nsMAPIConfiguration::GetMAPIConfiguration();
     if (pConfig != nullptr)