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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 10829444: Avoid trusting the length encoded in the Snapshot if there is an (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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
« no previous file with comments | « runtime/vm/dart.cc ('k') | runtime/vm/dart_api_message.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_impl.cc
===================================================================
--- runtime/vm/dart_api_impl.cc (revision 11409)
+++ runtime/vm/dart_api_impl.cc (working copy)
@@ -815,7 +815,7 @@
}
// Since this is only a snapshot the root library should not be set.
isolate->object_store()->set_root_library(Library::Handle(isolate));
- SnapshotWriter writer(Snapshot::kFull, buffer, ApiReallocate);
+ FullSnapshotWriter writer(buffer, ApiReallocate);
writer.WriteFullSnapshot();
*size = writer.BytesWritten();
return Api::Success(isolate);
@@ -946,24 +946,24 @@
intptr_t* data) {
uint8_t* buffer = NULL;
ApiMessageWriter writer(&buffer, &allocator);
-
writer.WriteMessage(len, data);
// Post the message at the given port.
return PortMap::PostMessage(new Message(
- port_id, Message::kIllegalPort, buffer, Message::kNormalPriority));
+ port_id, Message::kIllegalPort, buffer, writer.BytesWritten(),
+ Message::kNormalPriority));
}
DART_EXPORT bool Dart_PostCObject(Dart_Port port_id, Dart_CObject* message) {
uint8_t* buffer = NULL;
ApiMessageWriter writer(&buffer, allocator);
-
writer.WriteCMessage(message);
// Post the message at the given port.
return PortMap::PostMessage(new Message(
- port_id, Message::kIllegalPort, buffer, Message::kNormalPriority));
+ port_id, Message::kIllegalPort, buffer, writer.BytesWritten(),
+ Message::kNormalPriority));
}
@@ -973,11 +973,11 @@
DARTSCOPE_NOCHECKS(isolate);
const Object& object = Object::Handle(isolate, Api::UnwrapHandle(handle));
uint8_t* data = NULL;
- SnapshotWriter writer(Snapshot::kMessage, &data, &allocator);
- writer.WriteObject(object.raw());
- writer.FinalizeBuffer();
+ MessageWriter writer(&data, &allocator);
+ writer.WriteMessage(object);
+ intptr_t len = writer.BytesWritten();
return PortMap::PostMessage(new Message(
- port_id, Message::kIllegalPort, data, Message::kNormalPriority));
+ port_id, Message::kIllegalPort, data, len, Message::kNormalPriority));
}
@@ -3827,7 +3827,7 @@
const Snapshot* snapshot = Snapshot::SetupFromBuffer(buffer);
if (!snapshot->IsScriptSnapshot()) {
return Api::NewError("%s expects parameter 'buffer' to be a script type"
- " snapshot", CURRENT_FUNC);
+ " snapshot.", CURRENT_FUNC);
}
Library& library =
Library::Handle(isolate, isolate->object_store()->root_library());
@@ -3836,7 +3836,10 @@
return Api::NewError("%s: A script has already been loaded from '%s'.",
CURRENT_FUNC, library_url.ToCString());
}
- SnapshotReader reader(snapshot, isolate);
+ SnapshotReader reader(snapshot->content(),
+ snapshot->length(),
+ snapshot->kind(),
+ isolate);
const Object& tmp = Object::Handle(isolate, reader.ReadObject());
if (!tmp.IsLibrary()) {
return Api::NewError("%s: Unable to deserialize snapshot correctly.",
« no previous file with comments | « runtime/vm/dart.cc ('k') | runtime/vm/dart_api_message.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698