Bug 1334874 - Fix nsMsgTemplateReplyHelper leak as detected by test_autoReply.js. r=mkmelin a=jorgk
authoraleth <aleth@instantbird.org>
Mon, 06 Feb 2017 00:06:44 +0100
changeset 27756 4edf053c9916ff0f7e973ec964dd382807518090
parent 27755 f396c50306ceaf0785c91c753018939c04275e54
child 27757 8c61088f771604ef6f12ba2144a81a61941306ab
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)
reviewersmkmelin, jorgk
bugs1334874
Bug 1334874 - Fix nsMsgTemplateReplyHelper leak as detected by test_autoReply.js. r=mkmelin a=jorgk
mailnews/compose/src/nsMsgComposeService.cpp
--- a/mailnews/compose/src/nsMsgComposeService.cpp
+++ b/mailnews/compose/src/nsMsgComposeService.cpp
@@ -761,18 +761,16 @@ NS_IMETHODIMP nsMsgTemplateReplyHelper::
   nsCOMPtr<nsIMsgCompose> pMsgCompose (do_CreateInstance(NS_MSGCOMPOSE_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   /** initialize nsIMsgCompose, Send the message, wait for send completion response **/
 
   rv = pMsgCompose->Initialize(pMsgComposeParams, parentWindow, nullptr);
   NS_ENSURE_SUCCESS(rv,rv);
 
-  Release();
-
   return pMsgCompose->SendMsg(nsIMsgSend::nsMsgDeliverNow, mIdentity, nullptr, nullptr, nullptr) ;
 }
 
 NS_IMETHODIMP
 nsMsgTemplateReplyHelper::OnStartRequest(nsIRequest* request, nsISupports* aSupport)
 {
   return NS_OK;
 }
@@ -899,21 +897,17 @@ NS_IMETHODIMP nsMsgComposeService::Reply
     {
       identity = anIdentity;
       break;
     }
   }
   if (!identity) // Found no match -> don't reply.
     return NS_ERROR_ABORT;
 
-  nsMsgTemplateReplyHelper *helper = new nsMsgTemplateReplyHelper;
-  if (!helper)
-    return NS_ERROR_OUT_OF_MEMORY;
-
-  NS_ADDREF(helper);
+  RefPtr<nsMsgTemplateReplyHelper> helper = new nsMsgTemplateReplyHelper;
 
   helper->mHdrToReplyTo = aMsgHdr;
   helper->mMsgWindow = aMsgWindow;
   helper->mIdentity = identity;
 
   nsAutoCString replyTo;
   aMsgHdr->GetStringProperty("replyTo", getter_Copies(replyTo));
   if (replyTo.IsEmpty())