diff options
author | deanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-07 15:18:20 +0000 |
---|---|---|
committer | deanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-07 15:18:20 +0000 |
commit | 65b1094478e054ef1f924d3681f8d34ec88d9fcf (patch) | |
tree | 808f0e4fb2d81ba277b8be9b9aeeccfbddc76967 /base/pickle.cc | |
parent | 31da89e90326b507ae563951db780031e9f593f8 (diff) | |
download | chromium_src-65b1094478e054ef1f924d3681f8d34ec88d9fcf.zip chromium_src-65b1094478e054ef1f924d3681f8d34ec88d9fcf.tar.gz chromium_src-65b1094478e054ef1f924d3681f8d34ec88d9fcf.tar.bz2 |
Revert part of r508, it may have broken webkit-release-playback.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@514 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/pickle.cc')
-rw-r--r-- | base/pickle.cc | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/base/pickle.cc b/base/pickle.cc index 356d5df..0fb1d9c 100644 --- a/base/pickle.cc +++ b/base/pickle.cc @@ -309,21 +309,20 @@ char* Pickle::BeginWriteData(int length) { return data_ptr; } -void Pickle::TrimWriteData(int new_length) { +void Pickle::TrimWriteData(int length) { DCHECK(variable_buffer_offset_ != 0); - // Fetch the the variable buffer size - int* cur_length = reinterpret_cast<int*>( + VariableLengthBuffer *buffer = reinterpret_cast<VariableLengthBuffer*>( reinterpret_cast<char*>(header_) + variable_buffer_offset_); - if (new_length < 0 || new_length > *cur_length) { - NOTREACHED() << "Invalid length in TrimWriteData."; - return; - } + DCHECK_GE(buffer->length, length); - // Update the payload size and variable buffer size - header_->payload_size -= (*cur_length - new_length); - *cur_length = new_length; + int old_length = buffer->length; + int trimmed_bytes = old_length - length; + if (trimmed_bytes > 0) { + header_->payload_size -= trimmed_bytes; + buffer->length = length; + } } bool Pickle::Resize(size_t new_capacity) { |