Bug 1334874 - Fix nsMsgTemplateReplyHelper leak as detected by test_autoReply.js. r=mkmelin a=aleth
authoraleth <aleth@instantbird.org>
Mon, 06 Feb 2017 22:20:13 +0100
changeset 21107 6483fa45f5b2330a94edbb24ff7235170bce7830
parent 21106 65e6288d5b01073c7e2a0e9c83055c1457eccdc9
child 21108 1d0683ac7b096db2c99988c9d8cdf4423abdf87f
push id12822
push useraleth@instantbird.org
push dateMon, 06 Feb 2017 21:21:23 +0000
treeherdercomm-central@6483fa45f5b2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin, aleth
bugs1334874
Bug 1334874 - Fix nsMsgTemplateReplyHelper leak as detected by test_autoReply.js. r=mkmelin a=aleth
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())