diff options
author | thakis <thakis@chromium.org> | 2015-11-05 16:54:06 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-06 00:55:37 +0000 |
commit | de21d10374aeaa98eaaf4199c244249c1a93dc32 (patch) | |
tree | aa7b49c979482ee5b58f50b669626378e8428a3e /ipc | |
parent | e6b51fbf5c9043b120f98b2b3f78d2c86742acf2 (diff) | |
download | chromium_src-de21d10374aeaa98eaaf4199c244249c1a93dc32.zip chromium_src-de21d10374aeaa98eaaf4199c244249c1a93dc32.tar.gz chromium_src-de21d10374aeaa98eaaf4199c244249c1a93dc32.tar.bz2 |
Make sure IPC deserialization isn't O(n^2) in the message size.
There is no guarantee that
string s = ...;
s.assign(s.data(), s.size());
does O(1) work. In practice that's true almost everywhere, except on OS X
versions older than 10.9 with libc++. So add an explicit check for the
case where we're just assembling chunks of a single large IPC message, to
make sure that case is O(n) instead of O(n^2).
See comments 6, 8, and 10 on issue 547387 for details.
No intended behavior change, only makes deserialization of large
IPC messages much faster on older OS X versions.
BUG=547387,547872
Review URL: https://codereview.chromium.org/1415313010
Cr-Commit-Position: refs/heads/master@{#358211}
Diffstat (limited to 'ipc')
-rw-r--r-- | ipc/ipc_channel_reader.cc | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/ipc/ipc_channel_reader.cc b/ipc/ipc_channel_reader.cc index 335852f..e0cb2bf 100644 --- a/ipc/ipc_channel_reader.cc +++ b/ipc/ipc_channel_reader.cc @@ -122,7 +122,8 @@ bool ChannelReader::TranslateInputData(const char* input_data, 0; // Save any partial data in the overflow buffer. - input_overflow_buf_.assign(p, end - p); + if (p != input_overflow_buf_.data()) + input_overflow_buf_.assign(p, end - p); if (!input_overflow_buf_.empty()) { // We have something in the overflow buffer, which means that we will |