Bug 1217640 - MessageChannel::Call() should delete aMsg when the channel is not connected. r=jld
authorAndrew McCreight <continuation@gmail.com>
Mon, 26 Oct 2015 12:38:19 -0700
changeset 269649 4a87f75e1316e10ee5fad087762cb944d54ca0c1
parent 269648 05868efaa702fa95499e0f491305af36f02c2fe6
child 269650 66b3e867377493e29526e8d115ead25f39138fde
push id15905
push usercbook@mozilla.com
push dateTue, 27 Oct 2015 09:59:36 +0000
treeherderfx-team@60acc8a9cfb5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjld
bugs1217640
milestone44.0a1
Bug 1217640 - MessageChannel::Call() should delete aMsg when the channel is not connected. r=jld Otherwise, the message will leak.
ipc/glue/MessageChannel.cpp
--- a/ipc/glue/MessageChannel.cpp
+++ b/ipc/glue/MessageChannel.cpp
@@ -986,41 +986,40 @@ MessageChannel::Send(Message* aMsg, Mess
     *aReply = Move(*mRecvd);
     mRecvd = nullptr;
     return true;
 }
 
 bool
 MessageChannel::Call(Message* aMsg, Message* aReply)
 {
+    nsAutoPtr<Message> msg(aMsg);
     AssertWorkerThread();
     mMonitor->AssertNotCurrentThreadOwns();
 
 #ifdef OS_WIN
     SyncStackFrame frame(this, true);
 #endif
 
     // This must come before MonitorAutoLock, as its destructor acquires the
     // monitor lock.
-    CxxStackFrame cxxframe(*this, OUT_MESSAGE, aMsg);
+    CxxStackFrame cxxframe(*this, OUT_MESSAGE, msg);
 
     MonitorAutoLock lock(*mMonitor);
     if (!Connected()) {
-        ReportConnectionError("MessageChannel::Call", aMsg);
+        ReportConnectionError("MessageChannel::Call", msg);
         return false;
     }
 
     // Sanity checks.
     IPC_ASSERT(!AwaitingSyncReply(),
                "cannot issue Interrupt call while blocked on sync request");
     IPC_ASSERT(!DispatchingSyncMessage(),
                "violation of sync handler invariant");
-    IPC_ASSERT(aMsg->is_interrupt(), "can only Call() Interrupt messages here");
-
-    nsAutoPtr<Message> msg(aMsg);
+    IPC_ASSERT(msg->is_interrupt(), "can only Call() Interrupt messages here");
 
     msg->set_seqno(NextSeqno());
     msg->set_interrupt_remote_stack_depth_guess(mRemoteStackDepthGuess);
     msg->set_interrupt_local_stack_depth(1 + InterruptStackDepth());
     mInterruptStack.push(*msg);
     mLink->SendMessage(msg.forget());
 
     while (true) {