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

Unified Diff: src/d8.cc

Issue 1207453002: Fixed exception handling in Realm.create(). (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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 | « src/api.cc ('k') | test/mjsunit/regress/regress-crbug-501711.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/d8.cc
diff --git a/src/d8.cc b/src/d8.cc
index c46df53851a5fef9e39d1b02c829d8d7073a4308..3b3a0ef7c9f204026afdf62b55f38ad50d7b047e 100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -474,6 +474,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_;
@@ -483,8 +484,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);
}
« no previous file with comments | « src/api.cc ('k') | test/mjsunit/regress/regress-crbug-501711.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698