Bug 1226144 - Free sessionId after using it; a=jocheng
authorchunminchang <cchang@mozilla.com>
Tue, 29 Mar 2016 16:51:51 +0800
changeset 292693 fd9437a5f9a3
parent 292692 373f76c006f2
child 292694 4394647bdf0d
push id329
push usergachen@mozilla.com
push dateTue, 29 Mar 2016 08:53:36 +0000
reviewersjocheng
bugs1226144
milestone44.0
Bug 1226144 - Free sessionId after using it; a=jocheng MozReview-Commit-ID: C8rn6J8K8Do
dom/presentation/ipc/PresentationIPCService.cpp
--- a/dom/presentation/ipc/PresentationIPCService.cpp
+++ b/dom/presentation/ipc/PresentationIPCService.cpp
@@ -249,18 +249,21 @@ PresentationIPCService::NotifyReceiverRe
   if (NS_WARN_IF(aWindowId == 0)) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   // Track the responding info for an OOP receiver page.
   mRespondingSessionIds.Put(aWindowId, new nsAutoString(aSessionId));
   mRespondingWindowIds.Put(aSessionId, aWindowId);
 
+  NS_WARN_IF(!sPresentationChild->SendNotifyReceiverReady(nsAutoString(aSessionId)));
+
+  // Release mCallback after using aSessionId
+  // because aSessionId is held by mCallback.
   mCallback = nullptr;
-  NS_WARN_IF(!sPresentationChild->SendNotifyReceiverReady(nsAutoString(aSessionId)));
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PresentationIPCService::UntrackSessionInfo(const nsAString& aSessionId)
 {
   // Remove the OOP responding info (if it has never been used).
   uint64_t windowId = 0;