summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/pickle.cc2
-rw-r--r--base/pickle.h15
-rw-r--r--chrome/browser/extensions/api/messaging/native_message_process_host.cc3
-rw-r--r--chrome/tools/ipclist/ipcfuzz.cc2
4 files changed, 9 insertions, 13 deletions
diff --git a/base/pickle.cc b/base/pickle.cc
index 00c6ef0..af3191b 100644
--- a/base/pickle.cc
+++ b/base/pickle.cc
@@ -318,7 +318,7 @@ char* Pickle::BeginWrite(size_t length) {
#endif
header_->payload_size = static_cast<uint32>(new_size);
- return payload() + offset;
+ return mutable_payload() + offset;
}
void Pickle::EndWrite(char* dest, int length) {
diff --git a/base/pickle.h b/base/pickle.h
index cd587de..62dcd15 100644
--- a/base/pickle.h
+++ b/base/pickle.h
@@ -278,26 +278,23 @@ class BASE_EXPORT Pickle {
// The payload is the pickle data immediately following the header.
size_t payload_size() const { return header_->payload_size; }
+
const char* payload() const {
return reinterpret_cast<const char*>(header_) + header_size_;
}
- protected:
- char* payload() {
- return reinterpret_cast<char*>(header_) + header_size_;
- }
-
// Returns the address of the byte immediately following the currently valid
// header + payload.
- char* end_of_payload() {
- // We must have a valid header_.
- return payload() + payload_size();
- }
const char* end_of_payload() const {
// This object may be invalid.
return header_ ? payload() + payload_size() : NULL;
}
+ protected:
+ char* mutable_payload() {
+ return reinterpret_cast<char*>(header_) + header_size_;
+ }
+
size_t capacity() const {
return capacity_;
}
diff --git a/chrome/browser/extensions/api/messaging/native_message_process_host.cc b/chrome/browser/extensions/api/messaging/native_message_process_host.cc
index c431811..07fb1bd 100644
--- a/chrome/browser/extensions/api/messaging/native_message_process_host.cc
+++ b/chrome/browser/extensions/api/messaging/native_message_process_host.cc
@@ -165,8 +165,7 @@ bool NativeMessageProcessHost::WriteMessage(MessageType type,
// Make sure that the pickle doesn't do any unexpected padding.
CHECK(8 + message.length() == pickle.payload_size());
- if (!WriteData(write_file_, const_cast<const Pickle*>(&pickle)->payload(),
- pickle.payload_size())) {
+ if (!WriteData(write_file_, pickle.payload(), pickle.payload_size())) {
LOG(ERROR) << "Error writing message to the native client.";
return false;
}
diff --git a/chrome/tools/ipclist/ipcfuzz.cc b/chrome/tools/ipclist/ipcfuzz.cc
index 87fe2c2..5006307 100644
--- a/chrome/tools/ipclist/ipcfuzz.cc
+++ b/chrome/tools/ipclist/ipcfuzz.cc
@@ -501,7 +501,7 @@ struct FuzzTraits<gfx::Rect> {
class PickleCracker : public Pickle {
public:
static void CopyMessageID(PickleCracker *dst, PickleCracker *src) {
- memcpy(dst->payload(), src->payload(), sizeof(int));
+ memcpy(dst->mutable_payload(), src->payload(), sizeof(int));
}
};