Skip to content

Commit

Permalink
src: fix off-by-one error in native SetImmediate
Browse files Browse the repository at this point in the history
Previously, the throwing callback would have been re-executed in case
of an exception. This patch corrects the calculation to exclude the
callback.

PR-URL: #28082
Fixes: #26754
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
addaleax authored and BridgeAR committed Jun 17, 2019
1 parent 07ab591 commit b9d21e5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,11 @@ void Environment::RunAndClearNativeImmediates() {
if (!try_catch.HasTerminated())
FatalException(isolate(), try_catch);

// We are done with the current callback. Increase the counter so that
// the steps below make everything *after* the current item part of
// the new list.
it++;

// Bail out, remove the already executed callbacks from list
// and set up a new TryCatch for the other pending callbacks.
std::move_backward(it, list.end(), list.begin() + (list.end() - it));
Expand Down

0 comments on commit b9d21e5

Please sign in to comment.