Index: ipc/attachment_broker_privileged_win.cc |
diff --git a/ipc/attachment_broker_privileged_win.cc b/ipc/attachment_broker_privileged_win.cc |
index 38b2e652117bd64e8018a8d573781bbfcc5db2bb..c749a09c9802eef8f9475880d4e8c2ca000017c5 100644 |
--- a/ipc/attachment_broker_privileged_win.cc |
+++ b/ipc/attachment_broker_privileged_win.cc |
@@ -23,12 +23,13 @@ bool AttachmentBrokerPrivilegedWin::SendAttachmentToProcess( |
base::ProcessId destination_process) { |
switch (attachment->GetBrokerableType()) { |
case BrokerableAttachment::WIN_HANDLE: { |
- const internal::HandleAttachmentWin* handle_attachment = |
- static_cast<const internal::HandleAttachmentWin*>(attachment.get()); |
+ internal::HandleAttachmentWin* handle_attachment = |
+ static_cast<internal::HandleAttachmentWin*>(attachment.get()); |
HandleWireFormat wire_format = |
handle_attachment->GetWireFormat(destination_process); |
HandleWireFormat new_wire_format = |
DuplicateWinHandle(wire_format, base::Process::Current().Pid()); |
+ handle_attachment->reset_handle_ownership(); |
if (new_wire_format.handle == 0) |
return false; |
RouteDuplicatedHandle(new_wire_format); |
@@ -107,6 +108,10 @@ AttachmentBrokerPrivilegedWin::DuplicateWinHandle( |
if (source_pid == wire_format.destination_process) |
return wire_format; |
+ // If the handle is not valid, no additional work is required. |
+ if (wire_format.handle == 0) |
+ return wire_format; |
+ |
base::Process source_process = |
base::Process::OpenWithExtraPrivileges(source_pid); |
base::Process dest_process = |