summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2019-06-05 23:27:42 +0200
committerAnna Henningsen <anna@addaleax.net>2019-06-14 13:03:11 +0200
commitfb4d5286b05dd02054ae0e471ab9d3c3b3845381 (patch)
tree3dc8cbb039ea68a373b1808cb1dbe9b6d8c2bcd4 /src
parentb5e818197f127b36f18fb0d0481928227b88b053 (diff)
downloadandroid-node-v8-fb4d5286b05dd02054ae0e471ab9d3c3b3845381.tar.gz
android-node-v8-fb4d5286b05dd02054ae0e471ab9d3c3b3845381.tar.bz2
android-node-v8-fb4d5286b05dd02054ae0e471ab9d3c3b3845381.zip
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>
Diffstat (limited to 'src')
-rw-r--r--src/env.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/env.cc b/src/env.cc
index f541188e73..f0f4fc3068 100644
--- a/src/env.cc
+++ b/src/env.cc
@@ -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));