Skip to content

Commit 27f115d

Browse files
committed
src: fix Context::Scope usage
env->context() may or may not create a new Local. It currently does not but don't depend on that behavior, create a HandleScope first.
1 parent c0d62c2 commit 27f115d

17 files changed

Lines changed: 31 additions & 31 deletions

src/cares_wrap.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,8 @@ class QueryWrap : public AsyncWrap {
276276
}
277277

278278
void CallOnComplete(Local<Value> answer) {
279-
Context::Scope context_scope(env()->context());
280279
HandleScope handle_scope(env()->isolate());
280+
Context::Scope context_scope(env()->context());
281281
Local<Value> argv[] = {
282282
Integer::New(0, env()->isolate()),
283283
answer
@@ -286,8 +286,8 @@ class QueryWrap : public AsyncWrap {
286286
}
287287

288288
void CallOnComplete(Local<Value> answer, Local<Value> family) {
289-
Context::Scope context_scope(env()->context());
290289
HandleScope handle_scope(env()->isolate());
290+
Context::Scope context_scope(env()->context());
291291
Local<Value> argv[] = {
292292
Integer::New(0, env()->isolate()),
293293
answer,
@@ -298,8 +298,8 @@ class QueryWrap : public AsyncWrap {
298298

299299
void ParseError(int status) {
300300
assert(status != ARES_SUCCESS);
301-
Context::Scope context_scope(env()->context());
302301
HandleScope handle_scope(env()->isolate());
302+
Context::Scope context_scope(env()->context());
303303
Local<Value> arg;
304304
switch (status) {
305305
#define V(code) \
@@ -800,8 +800,8 @@ void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) {
800800
GetAddrInfoReqWrap* req_wrap = static_cast<GetAddrInfoReqWrap*>(req->data);
801801
Environment* env = req_wrap->env();
802802

803-
Context::Scope context_scope(env->context());
804803
HandleScope handle_scope(env->isolate());
804+
Context::Scope context_scope(env->context());
805805

806806
Local<Value> argv[] = {
807807
Integer::New(status, node_isolate),

src/env-inl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ inline Environment::Environment(v8::Local<v8::Context> context)
165165
using_smalloc_alloc_cb_(false),
166166
context_(context->GetIsolate(), context) {
167167
// We'll be creating new objects so make sure we've entered the context.
168-
v8::Context::Scope context_scope(context);
169168
v8::HandleScope handle_scope(isolate());
169+
v8::Context::Scope context_scope(context);
170170
set_binding_cache_object(v8::Object::New());
171171
set_module_load_list_array(v8::Array::New());
172172
RB_INIT(&cares_task_list_);

src/fs_event_wrap.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ void FSEventWrap::OnEvent(uv_fs_event_t* handle, const char* filename,
137137
FSEventWrap* wrap = static_cast<FSEventWrap*>(handle->data);
138138
Environment* env = wrap->env();
139139

140-
Context::Scope context_scope(env->context());
141140
HandleScope handle_scope(env->isolate());
141+
Context::Scope context_scope(env->context());
142142

143143
assert(wrap->persistent().IsEmpty() == false);
144144

src/handle_wrap.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ void HandleWrap::OnClose(uv_handle_t* handle) {
117117
// But the handle pointer should be gone.
118118
assert(wrap->handle__ == NULL);
119119

120-
Context::Scope context_scope(env->context());
121120
HandleScope handle_scope(env->isolate());
121+
Context::Scope context_scope(env->context());
122122
Local<Object> object = wrap->object();
123123

124124
if (wrap->flags_ & kCloseCallback) {

src/node.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3155,8 +3155,8 @@ void AtExit(void (*cb)(void* arg), void* arg) {
31553155

31563156
void EmitExit(Environment* env) {
31573157
// process.emit('exit')
3158-
Context::Scope context_scope(env->context());
31593158
HandleScope handle_scope(env->isolate());
3159+
Context::Scope context_scope(env->context());
31603160
Local<Object> process_object = env->process_object();
31613161
process_object->Set(FIXED_ONE_BYTE_STRING(node_isolate, "_exiting"),
31623162
True(node_isolate));

src/node_crypto.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,8 +1789,8 @@ void Connection::SSLInfoCallback(const SSL *ssl_, int where, int ret) {
17891789
SSL* ssl = const_cast<SSL*>(ssl_);
17901790
Connection* conn = static_cast<Connection*>(SSL_get_app_data(ssl));
17911791
Environment* env = conn->env();
1792-
Context::Scope context_scope(env->context());
17931792
HandleScope handle_scope(env->isolate());
1793+
Context::Scope context_scope(env->context());
17941794

17951795
if (where & SSL_CB_HANDSHAKE_START) {
17961796
conn->MakeCallback(env->onhandshakestart_string(), 0, NULL);
@@ -3447,8 +3447,8 @@ void EIO_PBKDF2After(uv_work_t* work_req, int status) {
34473447
assert(status == 0);
34483448
PBKDF2Request* req = CONTAINER_OF(work_req, PBKDF2Request, work_req_);
34493449
Environment* env = req->env();
3450-
Context::Scope context_scope(env->context());
34513450
HandleScope handle_scope(env->isolate());
3451+
Context::Scope context_scope(env->context());
34523452
Local<Value> argv[2];
34533453
EIO_PBKDF2After(req, argv);
34543454
req->MakeCallback(env->ondone_string(), ARRAY_SIZE(argv), argv);

src/node_file.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ static void After(uv_fs_t *req) {
109109
req_wrap->ReleaseEarly(); // Free memory that's no longer used now.
110110

111111
Environment* env = req_wrap->env();
112-
Context::Scope context_scope(env->context());
113112
HandleScope handle_scope(env->isolate());
113+
Context::Scope context_scope(env->context());
114114

115115
// there is always at least one argument. "error"
116116
int argc = 1;

src/node_stat_watcher.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ void StatWatcher::Callback(uv_fs_poll_t* handle,
8686
StatWatcher* wrap = static_cast<StatWatcher*>(handle->data);
8787
assert(wrap->watcher_ == handle);
8888
Environment* env = wrap->env();
89-
Context::Scope context_scope(env->context());
9089
HandleScope handle_scope(env->isolate());
90+
Context::Scope context_scope(env->context());
9191
Local<Value> argv[] = {
9292
BuildStatsObject(env, curr),
9393
BuildStatsObject(env, prev),
@@ -124,8 +124,8 @@ void StatWatcher::Start(const FunctionCallbackInfo<Value>& args) {
124124
void StatWatcher::Stop(const FunctionCallbackInfo<Value>& args) {
125125
StatWatcher* wrap = Unwrap<StatWatcher>(args.This());
126126
Environment* env = wrap->env();
127-
Context::Scope context_scope(env->context());
128127
HandleScope handle_scope(env->isolate());
128+
Context::Scope context_scope(env->context());
129129
wrap->MakeCallback(env->onstop_string(), 0, NULL);
130130
wrap->Stop();
131131
}

src/node_zlib.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,8 @@ class ZCtx : public WeakObject {
255255
ZCtx* ctx = CONTAINER_OF(work_req, ZCtx, work_req_);
256256
Environment* env = ctx->env();
257257

258-
Context::Scope context_scope(env->context());
259258
HandleScope handle_scope(env->isolate());
259+
Context::Scope context_scope(env->context());
260260

261261
// Acceptable error states depend on the type of zlib stream.
262262
switch (ctx->err_) {

src/pipe_wrap.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ void PipeWrap::OnConnection(uv_stream_t* handle, int status) {
181181
assert(&pipe_wrap->handle_ == reinterpret_cast<uv_pipe_t*>(handle));
182182

183183
Environment* env = pipe_wrap->env();
184-
Context::Scope context_scope(env->context());
185184
HandleScope handle_scope(env->isolate());
185+
Context::Scope context_scope(env->context());
186186

187187
// We should not be getting this callback if someone as already called
188188
// uv_close() on the handle.
@@ -220,8 +220,8 @@ void PipeWrap::AfterConnect(uv_connect_t* req, int status) {
220220
assert(req_wrap->env() == wrap->env());
221221
Environment* env = wrap->env();
222222

223-
Context::Scope context_scope(env->context());
224223
HandleScope handle_scope(env->isolate());
224+
Context::Scope context_scope(env->context());
225225

226226
// The wrap and request objects should still be there.
227227
assert(req_wrap->persistent().IsEmpty() == false);

0 commit comments

Comments
 (0)