Bug 1552355 - Port bug 1551782: Hand-roll removed nsCOMArray::Adopt(). rs=bustage-fix
authorJorg K <jorgk@jorgk.com>
Fri, 17 May 2019 00:23:11 +0200
changeset 26626 d05d70ad9d05bde2e19cab53929c98c1d3058fe9
parent 26625 9ec6e58a9d52e87a0dc3eb8bf5ad247d40efb744
child 26627 be424076627f1180bce256284a37ccee0399d16c
push id15926
push usermozilla@jorgk.com
push dateThu, 16 May 2019 22:32:11 +0000
treeherdercomm-central@d05d70ad9d05 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbustage-fix
bugs1552355, 1551782
Bug 1552355 - Port bug 1551782: Hand-roll removed nsCOMArray::Adopt(). rs=bustage-fix
mailnews/mime/public/msgIStructuredHeaders.idl
mailnews/mime/src/MimeHeaderParser.cpp
--- a/mailnews/mime/public/msgIStructuredHeaders.idl
+++ b/mailnews/mime/public/msgIStructuredHeaders.idl
@@ -119,17 +119,20 @@ interface msgIStructuredHeaders : nsISup
                                nsCOMArray<msgIAddressObject> &addrs,
                                bool aPreserveGroups = false)
   {
     msgIAddressObject **addrPtr;
     uint32_t length;
     nsresult rv = GetAddressingHeader(aPropertyName, aPreserveGroups, &length,
       &addrPtr);
     NS_ENSURE_SUCCESS(rv, rv);
-    addrs.Adopt(addrPtr, length);
+    // addrs.Adopt(addrPtr, length);
+    addrs.Clear();
+    addrs.AppendElements(addrPtr, length);
+    free(addrPtr);
     return NS_OK;
   }
 %}
 
 };
 
 /**
  * An interface that enhances msgIStructuredHeaders by allowing the values of
--- a/mailnews/mime/src/MimeHeaderParser.cpp
+++ b/mailnews/mime/src/MimeHeaderParser.cpp
@@ -71,17 +71,20 @@ nsCOMArray<msgIAddressObject> DecodedHea
   nsCOMPtr<nsIMsgHeaderParser> headerParser(services::GetHeaderParser());
   NS_ENSURE_TRUE(headerParser, retval);
   msgIAddressObject **addresses = nullptr;
   uint32_t length;
   nsresult rv =
       headerParser->ParseDecodedHeader(aHeader, false, &length, &addresses);
   MOZ_ASSERT(NS_SUCCEEDED(rv), "Javascript jsmime returned an error!");
   if (NS_SUCCEEDED(rv) && length > 0 && addresses) {
-    retval.Adopt(addresses, length);
+    // retval.Adopt(addresses, length);
+    retval.Clear();
+    retval.AppendElements(addresses, length);
+    free(addresses);
   }
   return retval;
 }
 
 nsCOMArray<msgIAddressObject> EncodedHeader(const nsACString &aHeader,
                                             const char *aCharset) {
   nsCOMArray<msgIAddressObject> retval;
   if (aHeader.IsEmpty()) {
@@ -90,34 +93,40 @@ nsCOMArray<msgIAddressObject> EncodedHea
   nsCOMPtr<nsIMsgHeaderParser> headerParser(services::GetHeaderParser());
   NS_ENSURE_TRUE(headerParser, retval);
   msgIAddressObject **addresses = nullptr;
   uint32_t length;
   nsresult rv = headerParser->ParseEncodedHeader(aHeader, aCharset, false,
                                                  &length, &addresses);
   MOZ_ASSERT(NS_SUCCEEDED(rv), "This should never fail!");
   if (NS_SUCCEEDED(rv) && length > 0 && addresses) {
-    retval.Adopt(addresses, length);
+    // retval.Adopt(addresses, length);
+    retval.Clear();
+    retval.AppendElements(addresses, length);
+    free(addresses);
   }
   return retval;
 }
 
 nsCOMArray<msgIAddressObject> EncodedHeaderW(const nsAString &aHeader) {
   nsCOMArray<msgIAddressObject> retval;
   if (aHeader.IsEmpty()) {
     return retval;
   }
   nsCOMPtr<nsIMsgHeaderParser> headerParser(services::GetHeaderParser());
   NS_ENSURE_TRUE(headerParser, retval);
   msgIAddressObject **addresses = nullptr;
   uint32_t length;
   nsresult rv = headerParser->ParseEncodedHeaderW(aHeader, &length, &addresses);
   MOZ_ASSERT(NS_SUCCEEDED(rv), "This should never fail!");
   if (NS_SUCCEEDED(rv) && length > 0 && addresses) {
-    retval.Adopt(addresses, length);
+    // retval.Adopt(addresses, length);
+    retval.Clear();
+    retval.AppendElements(addresses, length);
+    free(addresses);
   }
   return retval;
 }
 
 void ExtractAllAddresses(const nsCOMArray<msgIAddressObject> &aHeader,
                          nsTArray<nsString> &names,
                          nsTArray<nsString> &emails) {
   uint32_t count = aHeader.Length();