Skip to content

Commit dadcf6b

Browse files
bnoordhuisMylesBorins
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 7aa2689 commit dadcf6b

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
@@ -344,11 +344,11 @@ static void Close(const FunctionCallbackInfo<Value>& args) {
344344

345345

346346
Local<Value> BuildStatsObject(Environment* env, const uv_stat_t* s) {
347+
EscapableHandleScope handle_scope(env->isolate());
348+
347349
// If you hit this assertion, you forgot to enter the v8::Context first.
348350
CHECK_EQ(env->context(), env->isolate()->GetCurrentContext());
349351

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

0 commit comments

Comments
 (0)