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

Unified Diff: runtime/vm/service.cc

Issue 294473006: Disallow eval on lists containing non-instances. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 7 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 | « no previous file | runtime/vm/service_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/service.cc
===================================================================
--- runtime/vm/service.cc (revision 36381)
+++ runtime/vm/service.cc (working copy)
@@ -851,6 +851,23 @@
}
+static bool IsInternal(const Object& obj) {
turnidge 2014/05/20 23:21:34 The name is a bit vague. Not sure what to suggest
koda 2014/05/21 15:49:23 Done.
+ if (obj.IsArray()) {
turnidge 2014/05/20 23:21:34 Do you need to add a case for obj.IsGrowableArray
koda 2014/05/21 15:49:23 Good point. Done.
+ const Array& array = Array::Cast(obj);
+ Object& element = Object::Handle();
+ for (intptr_t i = 0; i < array.Length(); ++i) {
+ element = array.At(i);
+ if (!element.IsInstance()) {
+ return true;
+ }
+ }
+ return false;
+ } else {
+ return !obj.IsInstance();
+ }
+}
+
+
static bool HandleInstanceCommands(Isolate* isolate,
const Object& obj,
JSONStream* js,
@@ -876,6 +893,10 @@
js->num_arguments());
return true;
}
+ if (IsInternal(obj)) {
+ PrintError(js, "attempt to evaluate against internal VM object\n");
+ return true;
+ }
const char* expr = js->LookupOption("expr");
if (expr == NULL) {
PrintError(js, "eval expects an 'expr' option\n",
« no previous file with comments | « no previous file | runtime/vm/service_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698