summaryrefslogtreecommitdiff
path: root/lib/timers.js
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2017-05-10 20:59:04 -0700
committerRich Trott <rtrott@gmail.com>2017-05-12 22:18:18 -0700
commit98609fc1c4635f02f8f6ef9dd079207a1204b9a1 (patch)
tree3e12699ec1d1d4e4a596925771fd597e53160c1f /lib/timers.js
parent7c3a23b9c121b816c551d2560df9ee2bc63f2555 (diff)
downloadandroid-node-v8-98609fc1c4635f02f8f6ef9dd079207a1204b9a1.tar.gz
android-node-v8-98609fc1c4635f02f8f6ef9dd079207a1204b9a1.tar.bz2
android-node-v8-98609fc1c4635f02f8f6ef9dd079207a1204b9a1.zip
timers: do not use user object call/apply
Timers should work even if the user has monkey-patched `.call()` and `.apply()` to undesirable values. PR-URL: https://github.com/nodejs/node/pull/12960 Ref: https://github.com/nodejs/node/issues/12956 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'lib/timers.js')
-rw-r--r--lib/timers.js12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/timers.js b/lib/timers.js
index fb9984abf4..dd650d3c9a 100644
--- a/lib/timers.js
+++ b/lib/timers.js
@@ -485,20 +485,20 @@ function ontimeout(timer) {
if (typeof callback !== 'function')
return promiseResolve(callback, args[0]);
if (!args)
- callback.call(timer);
+ timer._onTimeout();
else {
switch (args.length) {
case 1:
- callback.call(timer, args[0]);
+ timer._onTimeout(args[0]);
break;
case 2:
- callback.call(timer, args[0], args[1]);
+ timer._onTimeout(args[0], args[1]);
break;
case 3:
- callback.call(timer, args[0], args[1], args[2]);
+ timer._onTimeout(args[0], args[1], args[2]);
break;
default:
- callback.apply(timer, args);
+ Function.prototype.apply.call(callback, timer, args);
}
}
if (timer._repeat)
@@ -806,7 +806,7 @@ function runCallback(timer) {
return timer._callback(argv[0], argv[1], argv[2]);
// more than 3 arguments run slower with .apply
default:
- return timer._callback.apply(timer, argv);
+ return Function.prototype.apply.call(timer._callback, timer, argv);
}
}