Index: mojo/edk/system/message_pipe_dispatcher.cc |
diff --git a/mojo/edk/system/message_pipe_dispatcher.cc b/mojo/edk/system/message_pipe_dispatcher.cc |
index 75f7227c9296e86531653c48bda07fc8ffd15453..b5bf7323282aeadafc3111a3461d034c6e142193 100644 |
--- a/mojo/edk/system/message_pipe_dispatcher.cc |
+++ b/mojo/edk/system/message_pipe_dispatcher.cc |
@@ -435,9 +435,14 @@ void MessagePipeDispatcher::CancelAllAwakablesNoLock() { |
} |
void MessagePipeDispatcher::CloseImplNoLock() { |
- lock().AssertAcquired(); |
+ lock().AssertAcquired(); |
+ // This early circuit fixes leak in unit tests. There's nothing to do in the |
+ // posted task. |
+ if (!transferable_ && non_transferable_state_ == CLOSED) |
+ return; |
+ |
// We take a manual refcount because at shutdown, the task below might not get |
- // a chance to execute. If that happens, the RawChannel's will still call our |
+ // a chance to execute. If that happens, the RawChannel will still call our |
// OnError method because it always runs (since it watches thread |
// destruction). So to avoid UAF, manually add a reference and only release it |
// if the task runs. |