| Index: mojo/edk/system/channel_posix.cc
|
| diff --git a/mojo/edk/system/channel_posix.cc b/mojo/edk/system/channel_posix.cc
|
| index bc759e0c159f4af0ed1b3f6a89661d8a35e79b95..8dac516bf02d77dab27c5751f70692a365041fa9 100644
|
| --- a/mojo/edk/system/channel_posix.cc
|
| +++ b/mojo/edk/system/channel_posix.cc
|
| @@ -140,20 +140,19 @@ class ChannelPosix : public Channel,
|
| // On OSX, we can have mach ports which are located in the extra header
|
| // section.
|
| using MachPortsEntry = Channel::Message::MachPortsEntry;
|
| - CHECK(extra_header_size >= num_handles * sizeof(MachPortsEntry));
|
| - size_t num_mach_ports = 0;
|
| - const MachPortsEntry* mach_ports =
|
| - reinterpret_cast<const MachPortsEntry*>(extra_header);
|
| - for (size_t i = 0; i < num_handles; i++) {
|
| - if (mach_ports[i].mach_port != MACH_PORT_NULL)
|
| - num_mach_ports++;
|
| - }
|
| + using MachPortsExtraHeader = Channel::Message::MachPortsExtraHeader;
|
| + CHECK(extra_header_size >=
|
| + sizeof(MachPortsExtraHeader) + num_handles * sizeof(MachPortsEntry));
|
| + const MachPortsExtraHeader* mach_ports_header =
|
| + reinterpret_cast<const MachPortsExtraHeader*>(extra_header);
|
| + size_t num_mach_ports = mach_ports_header->num_ports;
|
| CHECK(num_mach_ports <= num_handles);
|
| if (incoming_platform_handles_.size() + num_mach_ports < num_handles)
|
| return nullptr;
|
|
|
| ScopedPlatformHandleVectorPtr handles(
|
| new PlatformHandleVector(num_handles));
|
| + const MachPortsEntry* mach_ports = mach_ports_header->entries;
|
| for (size_t i = 0, mach_port_index = 0; i < num_handles; ++i) {
|
| if (mach_port_index < num_mach_ports &&
|
| mach_ports[mach_port_index].index == i) {
|
|
|