Bug 1175190 - Thunderbird 38 crashes in mozilla::mailnews::EncodedHeader [msvcr120.dll | nsCOMArray_base::Adopt | mozilla::mailnews::EncodedHeader]. r=rkent, a=rkent
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Mon, 22 Jun 2015 22:16:38 +0300
changeset 22115 e7bcc03ba8b184f375e4a71df50f9a561ba3bd92
parent 22114 b9c216025614c15199ad22097a676584718f7777
child 22116 01e25df7d11ad76477c300313dd52122c3333a86
push id13
push userkent@caspia.com
push dateTue, 30 Jun 2015 20:31:18 +0000
treeherdercomm-esr38@6a83ba854b14 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrkent, rkent
bugs1175190
Bug 1175190 - Thunderbird 38 crashes in mozilla::mailnews::EncodedHeader [msvcr120.dll | nsCOMArray_base::Adopt | mozilla::mailnews::EncodedHeader]. r=rkent, a=rkent
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();