Commit bcb276c6 authored by ishell's avatar ishell Committed by Commit bot

Fixed exception handling in Realm.create().

BUG=chromium:501711
LOG=N

Review URL: https://codereview.chromium.org/1207453002

Cr-Commit-Position: refs/heads/master@{#29236}
parent 93d62160
......@@ -5584,7 +5584,12 @@ Local<Context> v8::Context::New(
if (extensions == NULL) extensions = &no_extensions;
i::Handle<i::Context> env =
CreateEnvironment(isolate, extensions, global_template, global_object);
if (env.is_null()) return Local<Context>();
if (env.is_null()) {
if (isolate->has_pending_exception()) {
isolate->OptionalRescheduleException(true);
}
return Local<Context>();
}
return Utils::ToLocal(scope.CloseAndEscape(env));
}
......
......@@ -490,6 +490,7 @@ void Shell::RealmGlobal(const v8::FunctionCallbackInfo<v8::Value>& args) {
// Realm.create() creates a new realm and returns its index.
void Shell::RealmCreate(const v8::FunctionCallbackInfo<v8::Value>& args) {
Isolate* isolate = args.GetIsolate();
TryCatch try_catch(isolate);
PerIsolateData* data = PerIsolateData::Get(isolate);
Persistent<Context>* old_realms = data->realms_;
int index = data->realm_count_;
......@@ -500,8 +501,13 @@ void Shell::RealmCreate(const v8::FunctionCallbackInfo<v8::Value>& args) {
}
delete[] old_realms;
Handle<ObjectTemplate> global_template = CreateGlobalTemplate(isolate);
data->realms_[index].Reset(
isolate, Context::New(isolate, NULL, global_template));
Local<Context> context = Context::New(isolate, NULL, global_template);
if (context.IsEmpty()) {
DCHECK(try_catch.HasCaught());
try_catch.ReThrow();
return;
}
data->realms_[index].Reset(isolate, context);
args.GetReturnValue().Set(index);
}
......
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --stack-size=100
function f() {
try {
f();
} catch(e) {
Realm.create();
}
}
f();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment