diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-02-24 21:52:14 +0100 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-03-05 22:40:00 +0100 |
commit | c2f620ab76c3e42fa1fcdfde82aba7bcba3031e9 (patch) | |
tree | 05ae336d10e36944f1d65a7f7d72aeb12f58c6b6 /src/env-inl.h | |
parent | cc4e8e0696ffd5813df9cb50af7b47c27aaf2712 (diff) | |
download | android-node-v8-c2f620ab76c3e42fa1fcdfde82aba7bcba3031e9.tar.gz android-node-v8-c2f620ab76c3e42fa1fcdfde82aba7bcba3031e9.tar.bz2 android-node-v8-c2f620ab76c3e42fa1fcdfde82aba7bcba3031e9.zip |
src: refactor `Environment::GetCurrent(isolate)` usage
Do not require an explicit `HandleScope`, or the ability to create
one, when using `Environment::GetCurrent()`.
`isolate->InContext()` is used as an indicator that it is probably
okay to create a `HandleScope`, see also the short discussion in
https://github.com/nodejs/node/pull/25775#pullrequestreview-197371049.
PR-URL: https://github.com/nodejs/node/pull/26376
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/env-inl.h')
-rw-r--r-- | src/env-inl.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/env-inl.h b/src/env-inl.h index 6c4120fc2e..2a560f71d2 100644 --- a/src/env-inl.h +++ b/src/env-inl.h @@ -296,6 +296,8 @@ inline void Environment::AssignToContext(v8::Local<v8::Context> context, } inline Environment* Environment::GetCurrent(v8::Isolate* isolate) { + if (UNLIKELY(!isolate->InContext())) return nullptr; + v8::HandleScope handle_scope(isolate); return GetCurrent(isolate->GetCurrentContext()); } |