diff options
author | erikchen <erikchen@chromium.org> | 2015-11-28 17:08:21 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-29 01:09:04 +0000 |
commit | 3e15d1a2576e534e3674936022b40bedcf6f04e9 (patch) | |
tree | b1cd557d9d38581566dfb4c99be2feb5e1dd1744 /ipc | |
parent | 099dfdd09d2dd8e2d8228c955a89069fc971d625 (diff) | |
download | chromium_src-3e15d1a2576e534e3674936022b40bedcf6f04e9.zip chromium_src-3e15d1a2576e534e3674936022b40bedcf6f04e9.tar.gz chromium_src-3e15d1a2576e534e3674936022b40bedcf6f04e9.tar.bz2 |
ipc: Deallocate a Mach port if mach_msg fails.
When mach_msg succeeds, it decrements a reference on the send once right. When
it fails, the caller needs to do so.
BUG=561105
Review URL: https://codereview.chromium.org/1473053004
Cr-Commit-Position: refs/heads/master@{#362064}
Diffstat (limited to 'ipc')
-rw-r--r-- | ipc/attachment_broker_privileged_mac.cc | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/ipc/attachment_broker_privileged_mac.cc b/ipc/attachment_broker_privileged_mac.cc index f19f072..f4dc0439 100644 --- a/ipc/attachment_broker_privileged_mac.cc +++ b/ipc/attachment_broker_privileged_mac.cc @@ -40,13 +40,18 @@ kern_return_t SendMachPort(mach_port_t endpoint, send_msg.data.disposition = disposition; send_msg.data.type = MACH_MSG_PORT_DESCRIPTOR; - return mach_msg(&send_msg.header, - MACH_SEND_MSG | MACH_SEND_TIMEOUT, - send_msg.header.msgh_size, - 0, // receive limit - MACH_PORT_NULL, // receive name - 0, // timeout - MACH_PORT_NULL); // notification port + kern_return_t kr = + mach_msg(&send_msg.header, MACH_SEND_MSG | MACH_SEND_TIMEOUT, + send_msg.header.msgh_size, + 0, // receive limit + MACH_PORT_NULL, // receive name + 0, // timeout + MACH_PORT_NULL); // notification port + + if (kr != KERN_SUCCESS) + mach_port_deallocate(mach_task_self(), endpoint); + + return kr; } } // namespace |