Bug 1175190 - Thunderbird 38 crashes in mozilla::mailnews::EncodedHeader [msvcr120.dll | nsCOMArray_base::Adopt | mozilla::mailnews::EncodedHeader]. r=rkent a=IanN for SeaMonkey 2.35 CLOSED TREE SEAMONKEY_2_35_RELEASE_BRANCH
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Mon, 22 Jun 2015 22:16:38 +0300
branchSEAMONKEY_2_35_RELEASE_BRANCH
changeset 31178 7171d7f121da995b1cc995083873af4c021f2cef
parent 31177 09008d5431802c9a52eb942d9d1ee1ef244425da
child 31179 f45bcaa7cfb26ea5d747d9e817c21395dca15553
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)
reviewersrkent, IanN
bugs1175190
Bug 1175190 - Thunderbird 38 crashes in mozilla::mailnews::EncodedHeader [msvcr120.dll | nsCOMArray_base::Adopt | mozilla::mailnews::EncodedHeader]. r=rkent 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
@@ -66,38 +66,48 @@ void RemoveDuplicateAddresses(const nsAC
 }
 
 /////////////////////////////////////////////
 // These are the core shim methods we need //
 /////////////////////////////////////////////
 
 nsCOMArray<msgIAddressObject> DecodedHeader(const nsAString &aHeader)
 {
+  nsCOMArray<msgIAddressObject> retval;
+  if (aHeader.IsEmpty()) {
+    return retval;
+  }
   nsCOMPtr<nsIMsgHeaderParser> headerParser(services::GetHeaderParser());
   msgIAddressObject **addresses;
   uint32_t length;
   DebugOnly<nsresult> rv = headerParser->ParseDecodedHeader(aHeader, false,
     &length, &addresses);
   MOZ_ASSERT(NS_SUCCEEDED(rv), "This should never fail!");
-  nsCOMArray<msgIAddressObject> retval;
-  retval.Adopt(addresses, length);
+  if (length > 0) {
+    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;
   uint32_t length;
   DebugOnly<nsresult> rv = headerParser->ParseEncodedHeader(aHeader, aCharset,
     false, &length, &addresses);
   MOZ_ASSERT(NS_SUCCEEDED(rv), "This should never fail!");
-  nsCOMArray<msgIAddressObject> retval;
-  retval.Adopt(addresses, length);
+  if (length > 0) {
+    retval.Adopt(addresses, length);
+  }
   return retval;
 }
 
 void ExtractAllAddresses(const nsCOMArray<msgIAddressObject> &aHeader,
                          nsTArray<nsString> &names, nsTArray<nsString> &emails)
 {
   uint32_t count = aHeader.Length();