Bug 1175190 - Thunderbird 38 crashes in mozilla::mailnews::EncodedHeader [msvcr120.dll | nsCOMArray_base::Adopt | mozilla::mailnews::EncodedHeader]. r=rkent
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Mon, 22 Jun 2015 22:16:38 +0300
changeset 18048 f91e51cf26b7471c2052518597df7903835529f1
parent 18047 7170634c1998a94e9032c6798f78b5ab6adf51a3
child 18049 68e8683c28c63fd94d20a2628c58cc974fdc679b
push id11087
push usermkmelin@iki.fi
push dateMon, 22 Jun 2015 19:17:51 +0000
treeherdercomm-central@f91e51cf26b7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrkent
bugs1175190
Bug 1175190 - Thunderbird 38 crashes in mozilla::mailnews::EncodedHeader [msvcr120.dll | nsCOMArray_base::Adopt | mozilla::mailnews::EncodedHeader]. r=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();