Bug 1368042 - Port 1366584 to mailnews: Check status of ConstructX509(). rs=bustage-fix
authorJorg K <jorgk@jorgk.com>
Fri, 26 May 2017 17:04:43 +0200
changeset 28221 ba89157b81a79f4ca37bda1c86b445fe4ef826be
parent 28220 60de4a384f7e4c0e9bf34ecabaa211abfa2b65c4
child 28222 b55d3f67bf3f39efb06f7608e18be00b7baf8024
push id1966
push userclokep@gmail.com
push dateMon, 12 Jun 2017 16:57:35 +0000
treeherdercomm-beta@32d9b8d10da1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbustage-fix
bugs1368042, 1366584
Bug 1368042 - Port 1366584 to mailnews: Check status of ConstructX509(). rs=bustage-fix
mailnews/mime/src/nsCMS.cpp
mailnews/mime/src/nsCMSSecureMessage.cpp
--- a/mailnews/mime/src/nsCMS.cpp
+++ b/mailnews/mime/src/nsCMS.cpp
@@ -184,17 +184,18 @@ NS_IMETHODIMP nsCMSMessage::GetSignerCer
   nsCOMPtr<nsIX509Cert> cert;
   if (si->cert) {
     MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("nsCMSMessage::GetSignerCert got signer cert\n"));
 
     nsCOMPtr<nsIX509CertDB> certdb = do_GetService(NS_X509CERTDB_CONTRACTID);
     nsDependentCSubstring certDER(
       reinterpret_cast<char*>(si->cert->derCert.data),
       si->cert->derCert.len);
-    certdb->ConstructX509(certDER, getter_AddRefs(cert));
+    nsresult rv = certdb->ConstructX509(certDER, getter_AddRefs(cert));
+    NS_ENSURE_SUCCESS(rv, rv);
   }
   else {
     MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("nsCMSMessage::GetSignerCert no signer cert, do we have a cert list? %s\n",
       (si->certList ? "yes" : "no") ));
 
     *scert = nullptr;
   }
 
--- a/mailnews/mime/src/nsCMSSecureMessage.cpp
+++ b/mailnews/mime/src/nsCMSSecureMessage.cpp
@@ -116,28 +116,23 @@ DecodeCert(const char *value, nsIX509Cer
 
   nsCOMPtr<nsIX509CertDB> certdb = do_GetService(NS_X509CERTDB_CONTRACTID);
   if (!certdb) {
     return NS_ERROR_FAILURE;
   }
 
   nsDependentCSubstring certDER(reinterpret_cast<char*>(data), length);
   nsCOMPtr<nsIX509Cert> cert;
-  certdb->ConstructX509(certDER, getter_AddRefs(cert));
+  rv = certdb->ConstructX509(certDER, getter_AddRefs(cert));
+  NS_ENSURE_SUCCESS(rv, rv);
 
-  if (cert) {
-    *_retval = cert;
-    NS_ADDREF(*_retval);
-  }
-  else {
-    rv = NS_ERROR_FAILURE;
-  }
+  cert.forget(_retval);
+  free((char*)data);
 
-  free((char*)data);
-  return rv;
+  return NS_OK;
 }
 
 // nsCMSSecureMessage::SendMessage
 // Don't clash with Bill's versions SendMessageA or SendMessageW.
 #if defined (_MSC_VER)
 #undef SendMessage
 #endif
 NS_IMETHODIMP nsCMSSecureMessage::