mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
src: fix off-by-one error in native SetImmediate
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: https://github.com/nodejs/node/pull/28082 Fixes: https://github.com/nodejs/node/issues/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>
This commit is contained in:
1 parent
694faf13fb
commit
a5998152d5
1 file changed
+5
@@ -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));
|
||||
|
||||
Reference in new issue
Block a user