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

Unified Diff: ppapi/proxy/serialized_var.cc

Issue 16140011: Don't send PP_Vars/V8 values with cycles across PostMessage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months 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 side-by-side diff with in-line comments
Download patch
Index: ppapi/proxy/serialized_var.cc
diff --git a/ppapi/proxy/serialized_var.cc b/ppapi/proxy/serialized_var.cc
index 1217a83ba5cf6b645257a02e11f29fa0c7d74e3a..b9ca78c3d49d08653877f8e8ee7e6d0336af6e28 100644
--- a/ppapi/proxy/serialized_var.cc
+++ b/ppapi/proxy/serialized_var.cc
@@ -24,7 +24,8 @@ SerializedVar::Inner::Inner()
: serialization_rules_(NULL),
var_(PP_MakeUndefined()),
instance_(0),
- cleanup_mode_(CLEANUP_NONE) {
+ cleanup_mode_(CLEANUP_NONE),
+ is_valid_var_(true) {
#ifndef NDEBUG
has_been_serialized_ = false;
has_been_deserialized_ = false;
@@ -107,7 +108,14 @@ void SerializedVar::Inner::WriteToMessage(IPC::Message* m) const {
DCHECK(!has_been_serialized_);
has_been_serialized_ = true;
#endif
- RawVarDataGraph::Create(var_, instance_)->Write(m);
+ scoped_ptr<RawVarDataGraph> data =
+ RawVarDataGraph::Create(var_, instance_);
+ if (data) {
+ m->WriteBool(true); // Success.
+ data->Write(m);
+ } else {
+ m->WriteBool(false); // Failure.
+ }
}
bool SerializedVar::Inner::ReadFromMessage(const IPC::Message* m,
@@ -125,8 +133,15 @@ bool SerializedVar::Inner::ReadFromMessage(const IPC::Message* m,
#endif
// When reading, the dispatcher should be set when we get a Deserialize
// call (which will supply a dispatcher).
- raw_var_data_ = RawVarDataGraph::Read(m, iter);
- return raw_var_data_.get() != NULL;
+ if (!m->ReadBool(iter, &is_valid_var_))
+ return false;
+ if (is_valid_var_) {
+ raw_var_data_ = RawVarDataGraph::Read(m, iter);
+ if (!raw_var_data_)
+ return false;
+ }
+
+ return true;
}
void SerializedVar::Inner::SetCleanupModeToEndSendPassRef() {

Powered by Google App Engine
This is Rietveld 408576698