Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Side by Side Diff: base/pickle.h

Issue 4716006: Pickle: handle invalid data on 64 bit systems.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | base/pickle.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_PICKLE_H__ 5 #ifndef BASE_PICKLE_H__
6 #define BASE_PICKLE_H__ 6 #define BASE_PICKLE_H__
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 char* payload() { 170 char* payload() {
171 return reinterpret_cast<char*>(header_) + header_size_; 171 return reinterpret_cast<char*>(header_) + header_size_;
172 } 172 }
173 const char* payload() const { 173 const char* payload() const {
174 return reinterpret_cast<const char*>(header_) + header_size_; 174 return reinterpret_cast<const char*>(header_) + header_size_;
175 } 175 }
176 176
177 // Returns the address of the byte immediately following the currently valid 177 // Returns the address of the byte immediately following the currently valid
178 // header + payload. 178 // header + payload.
179 char* end_of_payload() { 179 char* end_of_payload() {
180 // We must have a valid header_.
180 return payload() + payload_size(); 181 return payload() + payload_size();
181 } 182 }
182 const char* end_of_payload() const { 183 const char* end_of_payload() const {
183 return payload() + payload_size(); 184 // This object may be invalid.
185 return header_ ? payload() + payload_size() : NULL;
184 } 186 }
185 187
186 size_t capacity() const { 188 size_t capacity() const {
187 return capacity_; 189 return capacity_;
188 } 190 }
189 191
190 // Resizes the buffer for use when writing the specified amount of data. The 192 // Resizes the buffer for use when writing the specified amount of data. The
191 // location that the data should be written at is returned, or NULL if there 193 // location that the data should be written at is returned, or NULL if there
192 // was an error. Call EndWrite with the returned offset and the given length 194 // was an error. Call EndWrite with the returned offset and the given length
193 // to pad out for the next write. 195 // to pad out for the next write.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 // Allocation size of payload (or -1 if allocation is const). 233 // Allocation size of payload (or -1 if allocation is const).
232 size_t capacity_; 234 size_t capacity_;
233 size_t variable_buffer_offset_; // IF non-zero, then offset to a buffer. 235 size_t variable_buffer_offset_; // IF non-zero, then offset to a buffer.
234 236
235 FRIEND_TEST_ALL_PREFIXES(PickleTest, Resize); 237 FRIEND_TEST_ALL_PREFIXES(PickleTest, Resize);
236 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNext); 238 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNext);
237 FRIEND_TEST_ALL_PREFIXES(PickleTest, IteratorHasRoom); 239 FRIEND_TEST_ALL_PREFIXES(PickleTest, IteratorHasRoom);
238 }; 240 };
239 241
240 #endif // BASE_PICKLE_H__ 242 #endif // BASE_PICKLE_H__
OLDNEW
« no previous file with comments | « no previous file | base/pickle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698