Chromium Code Reviews| Index: mojo/public/cpp/system/platform_handle.cc |
| diff --git a/mojo/public/cpp/system/platform_handle.cc b/mojo/public/cpp/system/platform_handle.cc |
| index 51dfc0ec898bf5fb05db34d4744d16e7463c4598..72af872b462191f466a86479fda4451e00e86974 100644 |
| --- a/mojo/public/cpp/system/platform_handle.cc |
| +++ b/mojo/public/cpp/system/platform_handle.cc |
| @@ -66,6 +66,13 @@ ScopedSharedBufferHandle WrapSharedMemoryHandle( |
| const base::SharedMemoryHandle& memory_handle, |
| size_t size, |
| bool read_only) { |
| +#if defined(OS_POSIX) && !(defined(OS_MACOSX) && !defined(OS_IOS)) |
| + if (memory_handle == base::kInvalidPlatformFile) |
|
yzshen1
2016/12/15 20:26:43
They are not compatible for comparison?
|
| + return ScopedSharedBufferHandle(); |
| +#else |
| + if (!memory_handle.IsValid()) |
| + return ScopedSharedBufferHandle(); |
| +#endif |
| MojoPlatformHandle platform_handle; |
| platform_handle.struct_size = sizeof(MojoPlatformHandle); |
| platform_handle.type = kPlatformSharedBufferHandleType; |
| @@ -96,6 +103,8 @@ MojoResult UnwrapSharedMemoryHandle(ScopedSharedBufferHandle handle, |
| base::SharedMemoryHandle* memory_handle, |
| size_t* size, |
| bool* read_only) { |
| + if (!handle.is_valid()) |
| + return MOJO_RESULT_INVALID_ARGUMENT; |
| MojoPlatformHandle platform_handle; |
| platform_handle.struct_size = sizeof(MojoPlatformHandle); |