Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
src: remove global HandleScope
Browse files Browse the repository at this point in the history
Make it more difficult to accidentally leak handles by removing the
top-level HandleScope.  Now if there's no valid HandleScope now, V8
will complain and, in debug builds, abort.
  • Loading branch information
bnoordhuis committed Nov 12, 2013
1 parent 09724b3 commit fd819ef
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/node.cc
Expand Up @@ -3249,8 +3249,11 @@ int Start(int argc, char** argv) {
Locker locker(node_isolate);
Environment* env =
CreateEnvironment(node_isolate, argc, argv, exec_argc, exec_argv);
// This Context::Scope is here so EnableDebug() can look up the current
// environment with Environment::GetCurrentChecked().
// TODO(bnoordhuis) Reorder the debugger initialization logic so it can
// be removed.
Context::Scope context_scope(env->context());
HandleScope handle_scope(env->isolate());
uv_run(env->event_loop(), UV_RUN_DEFAULT);
EmitExit(env);
RunAtExit(env);
Expand Down
3 changes: 1 addition & 2 deletions src/tls_wrap.cc
Expand Up @@ -235,9 +235,8 @@ void TLSCallbacks::SSLInfoCallback(const SSL* ssl_, int where, int ret) {
SSL* ssl = const_cast<SSL*>(ssl_);
TLSCallbacks* c = static_cast<TLSCallbacks*>(SSL_get_app_data(ssl));
Environment* env = c->env();
// There should be a Context::Scope a few stack frames down.
assert(env->context() == env->isolate()->GetCurrentContext());
HandleScope handle_scope(env->isolate());
Context::Scope context_scope(env->context());
Local<Object> object = c->object();

if (where & SSL_CB_HANDSHAKE_START) {
Expand Down

0 comments on commit fd819ef

Please sign in to comment.