Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
base: Fix shared memory handle leak in IPC serialization
PlatformSharedMemoryRegion leaked handles after serializing into the IPC message on Windows, Mac and Fuchsia. Serialization code incorrectly assumed that HandleWin, MachPortMac and HandleFuchsia classes take ownership over the handle. What really happens is that HandleFoo is passed to WriteParam(), which causes ParamTraits<HandleFoo>::Write() to be invoked, before it returns, creating the HandleAttachmentFoo, which will duplicate the handle. By the time we return from WriteParam() the handle should have been duplicated into the serialized message, so we can safely let the PSMR close the handle when it goes out of scope. This CL makes the PlatformSharedMemoryRegion serialization repeat the logic of the base::SharedMemoryHandle serialization as if the OwnershipPassesToIPC() flag is always set to true. Bug: 873313, 873668 Change-Id: I4e98ff9483a48970ebcb2fcf6b150f447af82794 Reviewed-on: https://chromium-review.googlesource.com/1175918 Commit-Queue: Wez <[email protected]> Reviewed-by: Daniel Cheng <[email protected]> Reviewed-by: Wez <[email protected]> Reviewed-by: Ken Rockot <[email protected]> Cr-Commit-Position: refs/heads/master@{#583434}
- Loading branch information