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

Unified Diff: src/runtime.cc

Issue 56002: Fix issue 289: check external source strings validity in Runtime_DebugGetLoadedScripts (Closed)
Patch Set: Added a comment as Soren suggests Created 11 years, 9 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 | test/cctest/test-debug.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index 9d4383e55f04e286d73ecfc46b00478d5cbe50de..5962b2ab1e3bb1f8dfa699ed94d4ba7435d4ccc1 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -6509,6 +6509,22 @@ static Object* Runtime_DebugEvaluateGlobal(Arguments args) {
}
+// If an object given is an external string, check that the underlying
+// resource is accessible. For other kinds of objects, always return true.
+static bool IsExternalStringValid(Object* str) {
+ if (!str->IsString() || !StringShape(String::cast(str)).IsExternal()) {
+ return true;
+ }
+ if (StringShape(String::cast(str)).IsAsciiRepresentation()) {
+ return ExternalAsciiString::cast(str)->resource() != 0;
+ } else if (StringShape(String::cast(str)).IsTwoByteRepresentation()) {
+ return ExternalTwoByteString::cast(str)->resource() != 0;
+ } else {
+ return true;
+ }
+}
+
+
// Helper function used by Runtime_DebugGetLoadedScripts below.
static int DebugGetLoadedScripts(FixedArray* instances, int instances_size) {
NoHandleAllocation ha;
@@ -6520,7 +6536,7 @@ static int DebugGetLoadedScripts(FixedArray* instances, int instances_size) {
while (iterator.has_next()) {
HeapObject* obj = iterator.next();
ASSERT(obj != NULL);
- if (obj->IsScript()) {
+ if (obj->IsScript() && IsExternalStringValid(Script::cast(obj)->source())) {
if (instances != NULL && count < instances_size) {
instances->set(count, obj);
}
« no previous file with comments | « no previous file | test/cctest/test-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698