Bug 1334874 - Fix nsMsgTemplateReplyHelper leak as detected by test_autoReply.js. r=mkmelin
authoraleth <aleth@instantbird.org>
Mon, 06 Feb 2017 00:06:44 +0100
changeset 21120 752aface26cafc254abf8871b6bc479cded5fcca
parent 21119 495a38b840265114c336b51877d0e3477dd524e8
child 21121 dae4f5ac532c2f224bd2f900c6795731a898c596
push id12830
push useraleth@instantbird.org
push dateWed, 08 Feb 2017 17:48:57 +0000
treeherdercomm-central@dae4f5ac532c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin
bugs1334874
Bug 1334874 - Fix nsMsgTemplateReplyHelper leak as detected by test_autoReply.js. r=mkmelin
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())