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 26107 f45bcaa7cfb26ea5d747d9e817c21395dca15553
parent 26106 7171d7f121da995b1cc995083873af4c021f2cef
child 26108 02705c8c21864689c4911aa09982f48e9dd989ee
push id1850
push userclokep@gmail.com
push dateWed, 08 Mar 2017 19:29:12 +0000
treeherdercomm-esr52@028df196b2d9 [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)
 {