Index: third_party/mojo/src/mojo/edk/system/raw_channel_posix.cc |
diff --git a/third_party/mojo/src/mojo/edk/system/raw_channel_posix.cc b/third_party/mojo/src/mojo/edk/system/raw_channel_posix.cc |
index d8c55d56b1b2bb3ef2b3f45c0ed53a60fdbeabe0..c2b2ef0730cee09d952f7461a2e1b55535ef7955 100644 |
--- a/third_party/mojo/src/mojo/edk/system/raw_channel_posix.cc |
+++ b/third_party/mojo/src/mojo/edk/system/raw_channel_posix.cc |
@@ -244,8 +244,10 @@ RawChannel::IOResult RawChannelPosix::WriteNoLock( |
write_result = embedder::PlatformChannelSendmsgWithHandles( |
fd_.get(), iov, buffer_count, platform_handles, num_platform_handles); |
- for (size_t i = 0; i < num_platform_handles; i++) |
- platform_handles[i].CloseIfNecessary(); |
+ if (write_result >= 0) { |
+ for (size_t i = 0; i < num_platform_handles; i++) |
+ platform_handles[i].CloseIfNecessary(); |
+ } |
} else { |
std::vector<WriteBuffer::Buffer> buffers; |
write_buffer_no_lock()->GetBuffers(&buffers); |