Bug 1177702, crash in EncodedHeader from incorrectly encoded UTF8 in header, r=mkmelin a=IanN for SeaMonkey 2.35 CLOSED TREE SEAMONKEY_2_35_RELEASE_BRANCH
authorR Kent James <rkent@caspia.com>
Wed, 01 Jul 2015 13:20:07 -0700
branchSEAMONKEY_2_35_RELEASE_BRANCH
changeset 31179 f45bcaa7cfb26ea5d747d9e817c21395dca15553
parent 31178 7171d7f121da995b1cc995083873af4c021f2cef
child 31180 02705c8c21864689c4911aa09982f48e9dd989ee
push id1
push userclokep@gmail.com
push dateMon, 07 May 2018 22:45:56 +0000
treeherdercomm-esr60@57eacde5ef40 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin, IanN
bugs1177702
Bug 1177702, crash in EncodedHeader from incorrectly encoded UTF8 in header, r=mkmelin a=IanN for SeaMonkey 2.35 CLOSED TREE
mailnews/mime/src/MimeHeaderParser.cpp
--- a/mailnews/mime/src/MimeHeaderParser.cpp
+++ b/mailnews/mime/src/MimeHeaderParser.cpp
@@ -71,41 +71,41 @@ void RemoveDuplicateAddresses(const nsAC
 
 nsCOMArray<msgIAddressObject> DecodedHeader(const nsAString &aHeader)
 {
   nsCOMArray<msgIAddressObject> retval;
   if (aHeader.IsEmpty()) {
     return retval;
   }
   nsCOMPtr<nsIMsgHeaderParser> headerParser(services::GetHeaderParser());
-  msgIAddressObject **addresses;
+  msgIAddressObject **addresses = nullptr;
   uint32_t length;
-  DebugOnly<nsresult> rv = headerParser->ParseDecodedHeader(aHeader, false,
+  nsresult rv = headerParser->ParseDecodedHeader(aHeader, false,
     &length, &addresses);
-  MOZ_ASSERT(NS_SUCCEEDED(rv), "This should never fail!");
-  if (length > 0) {
+  MOZ_ASSERT(NS_SUCCEEDED(rv), "Javascript jsmime returned an error!");
+  if (NS_SUCCEEDED(rv) && length > 0 && addresses) {
     retval.Adopt(addresses, length);
   }
   return retval;
 }
 
 nsCOMArray<msgIAddressObject> EncodedHeader(const nsACString &aHeader,
                                             const char *aCharset)
 {
   nsCOMArray<msgIAddressObject> retval;
   if (aHeader.IsEmpty()) {
     return retval;
   }
   nsCOMPtr<nsIMsgHeaderParser> headerParser(services::GetHeaderParser());
-  msgIAddressObject **addresses;
+  msgIAddressObject **addresses = nullptr;
   uint32_t length;
-  DebugOnly<nsresult> rv = headerParser->ParseEncodedHeader(aHeader, aCharset,
+  nsresult rv = headerParser->ParseEncodedHeader(aHeader, aCharset,
     false, &length, &addresses);
   MOZ_ASSERT(NS_SUCCEEDED(rv), "This should never fail!");
-  if (length > 0) {
+  if (NS_SUCCEEDED(rv) && length > 0 && addresses) {
     retval.Adopt(addresses, length);
   }
   return retval;
 }
 
 void ExtractAllAddresses(const nsCOMArray<msgIAddressObject> &aHeader,
                          nsTArray<nsString> &names, nsTArray<nsString> &emails)
 {