Index: mojo/system/raw_channel_posix.cc |
diff --git a/mojo/system/raw_channel_posix.cc b/mojo/system/raw_channel_posix.cc |
index 0038afbd2ba8ab08e9363a0e9b28d0557e31abc3..fa9d5f29239dddb1bc99bc9ba4522916fefb35d7 100644 |
--- a/mojo/system/raw_channel_posix.cc |
+++ b/mojo/system/raw_channel_posix.cc |
@@ -296,8 +296,10 @@ void RawChannelPosix::OnFileCanReadWithoutBlocking(int fd) { |
// Move data back to start. |
if (read_buffer_start > 0) { |
- memmove(&read_buffer_[0], &read_buffer_[read_buffer_start], |
- read_buffer_num_valid_bytes_); |
+ if (read_buffer_num_valid_bytes_ > 0) { |
+ memmove(&read_buffer_[0], &read_buffer_[read_buffer_start], |
+ read_buffer_num_valid_bytes_); |
+ } |
read_buffer_start = 0; |
} |
} |