Skip to content

Commit dc766e6

Browse files
bnoordhuisevanlucas
authored andcommitted
src: fix handle leak in BuildStatsObject()
Create a handle scope before performing a check that creates a handle, otherwise the handle is leaked into the handle scope of the caller. PR-URL: #7711 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Trevor Norris <[email protected]>
1 parent 96882e1 commit dc766e6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/node_file.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -420,11 +420,11 @@ static void Close(const FunctionCallbackInfo<Value>& args) {
420420

421421

422422
Local<Value> BuildStatsObject(Environment* env, const uv_stat_t* s) {
423+
EscapableHandleScope handle_scope(env->isolate());
424+
423425
// If you hit this assertion, you forgot to enter the v8::Context first.
424426
CHECK_EQ(env->context(), env->isolate()->GetCurrentContext());
425427

426-
EscapableHandleScope handle_scope(env->isolate());
427-
428428
// The code below is very nasty-looking but it prevents a segmentation fault
429429
// when people run JS code like the snippet below. It's apparently more
430430
// common than you would expect, several people have reported this crash...

0 commit comments

Comments
 (0)