timers: fix unsafe array iteration

Fixes: https://github.com/nodejs/node/issues/37222

PR-URL: https://github.com/nodejs/node/pull/37223
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
Darshan Sen 2021-02-04 18:19:37 +05:30 committed by Rich Trott
parent 3aba6fef07
commit c0e66e3e9d

View File

@ -79,6 +79,7 @@ const {
NumberMIN_SAFE_INTEGER, NumberMIN_SAFE_INTEGER,
ObjectCreate, ObjectCreate,
Symbol, Symbol,
ReflectApply,
} = primordials; } = primordials;
const { const {
@ -555,7 +556,7 @@ function getTimerCallbacks(runNextTicks) {
if (args === undefined) if (args === undefined)
timer._onTimeout(); timer._onTimeout();
else else
timer._onTimeout(...args); ReflectApply(timer._onTimeout, timer, args);
} finally { } finally {
if (timer._repeat && timer._idleTimeout !== -1) { if (timer._repeat && timer._idleTimeout !== -1) {
timer._idleTimeout = timer._repeat; timer._idleTimeout = timer._repeat;