Fix null dereference after OOM.
authoryangguo@chromium.org <yangguo@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 3 Dec 2012 17:57:17 +0000 (17:57 +0000)
committeryangguo@chromium.org <yangguo@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 3 Dec 2012 17:57:17 +0000 (17:57 +0000)
R=mstarzinger@chromium.org
BUG=

Review URL: https://chromiumcodereview.appspot.com/11414295

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13121 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/debug.cc
test/cctest/test-debug.cc

index ec25acc..ea1c084 100644 (file)
@@ -786,9 +786,11 @@ bool Debug::CompileDebuggerScript(int index) {
         "error_loading_debugger", &computed_location,
         Vector<Handle<Object> >::empty(), Handle<String>(), Handle<JSArray>());
     ASSERT(!isolate->has_pending_exception());
-    isolate->set_pending_exception(*exception);
-    MessageHandler::ReportMessage(Isolate::Current(), NULL, message);
-    isolate->clear_pending_exception();
+    if (!exception.is_null()) {
+      isolate->set_pending_exception(*exception);
+      MessageHandler::ReportMessage(Isolate::Current(), NULL, message);
+      isolate->clear_pending_exception();
+    }
     return false;
   }
 
index 941fa68..8d97cd8 100644 (file)
@@ -7532,4 +7532,18 @@ TEST(LiveEditDisabled) {
 }
 
 
+TEST(DebugContextOOM) {
+  v8::HandleScope scope;
+  LocalContext context;
+  v8::V8::IgnoreOutOfMemoryException();
+
+  v8::Local<v8::Value> result = CompileRun("a = '1'; while (true) a += a;");
+
+  // Check for out of memory state.
+  CHECK(result.IsEmpty());
+  CHECK(context->HasOutOfMemoryException());
+
+  v8::Debug::GetDebugContext();
+}
+
 #endif  // ENABLE_DEBUGGER_SUPPORT