Skip to content

Commit

Permalink
src: fix handle leak in BuildStatsObject()
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
bnoordhuis authored and MylesBorins committed Oct 26, 2016
1 parent 7aa2689 commit dadcf6b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -344,11 +344,11 @@ static void Close(const FunctionCallbackInfo<Value>& args) {


Local<Value> BuildStatsObject(Environment* env, const uv_stat_t* s) {
EscapableHandleScope handle_scope(env->isolate());

// If you hit this assertion, you forgot to enter the v8::Context first.
CHECK_EQ(env->context(), env->isolate()->GetCurrentContext());

EscapableHandleScope handle_scope(env->isolate());

// The code below is very nasty-looking but it prevents a segmentation fault
// when people run JS code like the snippet below. It's apparently more
// common than you would expect, several people have reported this crash...
Expand Down

0 comments on commit dadcf6b

Please sign in to comment.