Bug 1360803 - Add error checking to getting nsIMimeConverter service to avoid crash. r=jorgk
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Mon, 24 Sep 2018 18:21:21 +0300
changeset 33231 34eaca00ed364f73e4b43c1240e1d8a900655bce
parent 33230 d900f4b75757f47d21d8c9404488438c7724e877
child 33232 9cbdc6469caf6126896fcee4803f920a316a8172
push id387
push userclokep@gmail.com
push dateMon, 10 Dec 2018 21:30:47 +0000
reviewersjorgk
bugs1360803
Bug 1360803 - Add error checking to getting nsIMimeConverter service to avoid crash. r=jorgk
mailnews/base/search/src/nsMsgSearchTerm.cpp
mailnews/compose/src/nsSmtpUrl.cpp
--- a/mailnews/base/search/src/nsMsgSearchTerm.cpp
+++ b/mailnews/base/search/src/nsMsgSearchTerm.cpp
@@ -1073,19 +1073,21 @@ nsresult nsMsgSearchTerm::MatchInAddress
 // *pResult is false when strings don't match, true if they do.
 nsresult nsMsgSearchTerm::MatchRfc2047String(const nsACString &rfc2047string,
                                              const char *charset,
                                              bool charsetOverride,
                                              bool *pResult)
 {
   NS_ENSURE_ARG_POINTER(pResult);
 
-  nsCOMPtr<nsIMimeConverter> mimeConverter = do_GetService(NS_MIME_CONVERTER_CONTRACTID);
+  nsresult rv;
+  nsCOMPtr<nsIMimeConverter> mimeConverter = do_GetService(NS_MIME_CONVERTER_CONTRACTID, &rv);
+  NS_ENSURE_SUCCESS(rv, rv);
   nsAutoString stringToMatch;
-  nsresult rv = mimeConverter->DecodeMimeHeader(
+  rv = mimeConverter->DecodeMimeHeader(
     PromiseFlatCString(rfc2047string).get(), charset, charsetOverride, false,
     stringToMatch);
   NS_ENSURE_SUCCESS(rv, rv);
   if (m_operator == nsMsgSearchOp::IsInAB ||
       m_operator == nsMsgSearchOp::IsntInAB)
     return MatchInAddressBook(stringToMatch, pResult);
 
   return MatchString(stringToMatch, pResult);
--- a/mailnews/compose/src/nsSmtpUrl.cpp
+++ b/mailnews/compose/src/nsSmtpUrl.cpp
@@ -201,19 +201,21 @@ nsresult nsMailtoUrl::ParseMailtoUrl(cha
       } // end of switch statement...
 
       if (eq)
         *eq = '='; /* put it back */
       token = NS_strtok("&", &rest);
     } // while we still have part of the url to parse...
   } // if rest && *rest
 
+  nsresult rv;
   // Get a global converter
   nsCOMPtr<nsIMimeConverter> mimeConverter =
-    do_GetService(NS_MIME_CONVERTER_CONTRACTID);
+    do_GetService(NS_MIME_CONVERTER_CONTRACTID, &rv);
+  NS_ENSURE_SUCCESS(rv, rv);
 
   // Now unescape everything, and mime-decode the things that can be encoded.
   UnescapeAndConvert(mimeConverter, escapedToPart, m_toPart);
   UnescapeAndConvert(mimeConverter, escapedCcPart, m_ccPart);
   UnescapeAndConvert(mimeConverter, escapedBccPart, m_bccPart);
   UnescapeAndConvert(mimeConverter, escapedSubjectPart, m_subjectPart);
   UnescapeAndConvert(mimeConverter, escapedNewsgroupPart, m_newsgroupPart);
   UnescapeAndConvert(mimeConverter, escapedReferencePart, m_referencePart);