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 26165 84bf7d2167f52fd07cf3c4d71da7ca61da6c11e9
parent 26164 1fbfd45dfb252479dc313f6ffbfb0e97b3d2f8dd
child 26166 fa2c109afd49e23eaea28c615d435faaded03f84
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)
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();