Skip to content

Commit

Permalink
Fix leak of PlatformHandleDispatchers in Mojo IPC
Browse files Browse the repository at this point in the history
PassWrappedPlatformHandle does not close the MojoHandle.
The destructor of ScopedHandleBase will however close it.
The problem with this code was that it called release()
on the ScopedHandle, preventing the destructor from being
called, and thus also the MojoHandle from being closed.

This leaves the PlatformHandleDispatcher associated with
the MojoHandle alive in mojo::system::Core::handle_table_

By calling reset() instead the MojoHandle is closed, and
the leak is fixed.

R=morrita@chromium.org, viettrungluu@chromium.org, agl@chromium.org

BUG=None

Review URL: https://codereview.chromium.org/1174423002

Cr-Commit-Position: refs/heads/master@{#334197}
  • Loading branch information
rogerj authored and Commit bot committed Jun 12, 2015
1 parent f771be4 commit b213436
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ipc/mojo/ipc_mojo_handle_attachment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ MessageAttachment::Type MojoHandleAttachment::GetType() const {
base::PlatformFile MojoHandleAttachment::TakePlatformFile() {
mojo::embedder::ScopedPlatformHandle platform_handle;
MojoResult unwrap_result = mojo::embedder::PassWrappedPlatformHandle(
handle_.release().value(), &platform_handle);
handle_.get().value(), &platform_handle);
handle_.reset();
if (unwrap_result != MOJO_RESULT_OK) {
LOG(ERROR) << "Pipe failed to covert handles. Closing: " << unwrap_result;
return -1;
Expand Down

0 comments on commit b213436

Please sign in to comment.