Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit def8dea

Browse filesBrowse files
indutnyrvagg
authored andcommitted
contextify: ignore getters during initialization
The `context_` is not initialized until the `CreateV8Context` will return. Make sure that it will be empty (by moving away initialization from constructor) at start, and ignore getter callbacks until it will have some value. PR-URL: #2091 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
1 parent b30f393 commit def8dea
Copy full SHA for def8dea

File tree

Expand file treeCollapse file tree

1 file changed

+23
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+23
-1
lines changed
Open diff view settings
Collapse file

‎src/node_contextify.cc‎

Copy file name to clipboardExpand all lines: src/node_contextify.cc
+23-1Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@ class ContextifyContext {
6565
explicit ContextifyContext(Environment* env, Local<Object> sandbox)
6666
: env_(env),
6767
sandbox_(env->isolate(), sandbox),
68-
context_(env->isolate(), CreateV8Context(env)),
6968
// Wait for sandbox_, proxy_global_, and context_ to die
7069
references_(0) {
70+
context_.Reset(env->isolate(), CreateV8Context(env));
71+
7172
sandbox_.SetWeak(this, WeakCallback<Object, kSandbox>);
7273
sandbox_.MarkIndependent();
7374
references_++;
@@ -355,6 +356,10 @@ class ContextifyContext {
355356
ContextifyContext* ctx =
356357
Unwrap<ContextifyContext>(args.Data().As<Object>());
357358

359+
// Stil initializing
360+
if (ctx->context_.IsEmpty())
361+
return;
362+
358363
Local<Object> sandbox = PersistentToLocal(isolate, ctx->sandbox_);
359364
MaybeLocal<Value> maybe_rv =
360365
sandbox->GetRealNamedProperty(ctx->context(), property);
@@ -383,6 +388,10 @@ class ContextifyContext {
383388
ContextifyContext* ctx =
384389
Unwrap<ContextifyContext>(args.Data().As<Object>());
385390

391+
// Stil initializing
392+
if (ctx->context_.IsEmpty())
393+
return;
394+
386395
PersistentToLocal(isolate, ctx->sandbox_)->Set(property, value);
387396
}
388397

@@ -395,6 +404,10 @@ class ContextifyContext {
395404
ContextifyContext* ctx =
396405
Unwrap<ContextifyContext>(args.Data().As<Object>());
397406

407+
// Stil initializing
408+
if (ctx->context_.IsEmpty())
409+
return;
410+
398411
Local<Object> sandbox = PersistentToLocal(isolate, ctx->sandbox_);
399412
Maybe<PropertyAttribute> maybe_prop_attr =
400413
sandbox->GetRealNamedPropertyAttributes(ctx->context(), property);
@@ -422,6 +435,11 @@ class ContextifyContext {
422435

423436
ContextifyContext* ctx =
424437
Unwrap<ContextifyContext>(args.Data().As<Object>());
438+
439+
// Stil initializing
440+
if (ctx->context_.IsEmpty())
441+
return;
442+
425443
Local<Object> sandbox = PersistentToLocal(isolate, ctx->sandbox_);
426444

427445
Maybe<bool> success = sandbox->Delete(ctx->context(), property);
@@ -436,6 +454,10 @@ class ContextifyContext {
436454
ContextifyContext* ctx =
437455
Unwrap<ContextifyContext>(args.Data().As<Object>());
438456

457+
// Stil initializing
458+
if (ctx->context_.IsEmpty())
459+
return;
460+
439461
Local<Object> sandbox = PersistentToLocal(args.GetIsolate(), ctx->sandbox_);
440462
args.GetReturnValue().Set(sandbox->GetPropertyNames());
441463
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.