Skip to content

Commit

Permalink
Fixed crash if evaluate() times out.
Browse files Browse the repository at this point in the history
  • Loading branch information
SLiV9 committed Apr 13, 2017
1 parent 87adab7 commit a212662
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,17 @@ Php::Value Context::evaluate(Php::Parameters &params)
status = condition.wait_until(lock, end);
}

// in case we timeout we terminate execution
if (status == std::cv_status::timeout) _context->GetIsolate()->TerminateExecution();
// in case we timeout we must terminate execution
if (status != std::cv_status::timeout) return;

// create a handle, so the local variable created below falls out of scope
v8::HandleScope scope(Isolate::get());

// access the main threads context
v8::Local<v8::Context> context(_context);

// terminate execution
context->GetIsolate()->TerminateExecution();
}));

// execute the script
Expand Down

0 comments on commit a212662

Please sign in to comment.