diff options
author | maruel@google.com <maruel@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-07 17:04:23 +0000 |
---|---|---|
committer | maruel@google.com <maruel@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-07 17:04:23 +0000 |
commit | 9f16de03664224cc286851ca03369cf699dd7c3c (patch) | |
tree | cb5555629b34c68845617ee07125ac1d32df3e2c | |
parent | 599664e48f443091d8e686e72928fd4df36898b0 (diff) | |
download | chromium_src-9f16de03664224cc286851ca03369cf699dd7c3c.zip chromium_src-9f16de03664224cc286851ca03369cf699dd7c3c.tar.gz chromium_src-9f16de03664224cc286851ca03369cf699dd7c3c.tar.bz2 |
Reapply 508 to determine if it was indeed the cause of the webkit-release-playback failure.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@518 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/pickle.cc | 19 | ||||
-rw-r--r-- | base/pickle.h | 6 |
2 files changed, 10 insertions, 15 deletions
diff --git a/base/pickle.cc b/base/pickle.cc index 0fb1d9c..356d5df 100644 --- a/base/pickle.cc +++ b/base/pickle.cc @@ -309,20 +309,21 @@ char* Pickle::BeginWriteData(int length) { return data_ptr; } -void Pickle::TrimWriteData(int length) { +void Pickle::TrimWriteData(int new_length) { DCHECK(variable_buffer_offset_ != 0); - VariableLengthBuffer *buffer = reinterpret_cast<VariableLengthBuffer*>( + // Fetch the the variable buffer size + int* cur_length = reinterpret_cast<int*>( reinterpret_cast<char*>(header_) + variable_buffer_offset_); - DCHECK_GE(buffer->length, length); - - int old_length = buffer->length; - int trimmed_bytes = old_length - length; - if (trimmed_bytes > 0) { - header_->payload_size -= trimmed_bytes; - buffer->length = length; + if (new_length < 0 || new_length > *cur_length) { + NOTREACHED() << "Invalid length in TrimWriteData."; + return; } + + // Update the payload size and variable buffer size + header_->payload_size -= (*cur_length - new_length); + *cur_length = new_length; } bool Pickle::Resize(size_t new_capacity) { diff --git a/base/pickle.h b/base/pickle.h index 7c4a007..da2a485 100644 --- a/base/pickle.h +++ b/base/pickle.h @@ -239,12 +239,6 @@ class Pickle { static const int kPayloadUnit; private: - // A buffer of variable length; used internally - struct VariableLengthBuffer { - int length; - char data; // This is variable length. - }; - Header* header_; size_t header_size_; // Supports extra data between header and payload. // Allocation size of payload (or -1 if allocation is const). |