From 9b8837b3554cb38fe9412922f064529329f5fff7 Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Wed, 3 Sep 2014 14:24:50 -0700 Subject: [PATCH] src: be more intelligent about use of "arguments" Use 'use strict' when there are named arguments and the arguments object is passed to apply(). Also pass named arguments to call() when the named argument is modified by the function. Suggested in https://github.com/joyent/node/pull/8302#issuecomment-54331801 Confirmed in https://github.com/joyent/node/pull/8302#issuecomment-54364818 Signed-off-by: Trevor Norris --- lib/child_process.js | 3 ++- lib/cluster.js | 2 ++ lib/net.js | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/child_process.js b/lib/child_process.js index aadac2ed288..23963828c0c 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -454,7 +454,8 @@ function setupChannel(target, channel) { var obj = handleConversion[message.type]; // convert TCP object to native handle object - handle = handleConversion[message.type].send.apply(target, arguments); + handle = + handleConversion[message.type].send.call(target, message, handle); // If handle was sent twice, or it is impossible to get native handle // out of it - just send a text without the handle. diff --git a/lib/cluster.js b/lib/cluster.js index 0914546b9ee..c994f433b96 100644 --- a/lib/cluster.js +++ b/lib/cluster.js @@ -662,6 +662,8 @@ function sendHelper(proc, message, handle, cb) { // to the callback but intercepts and redirects ACK messages. function internal(worker, cb) { return function(message, handle) { + 'use strict'; + if (message.cmd !== 'NODE_CLUSTER') return; var fn = cb; if (!util.isUndefined(message.ack)) { diff --git a/lib/net.js b/lib/net.js index c2f320d75ad..ddace957b42 100644 --- a/lib/net.js +++ b/lib/net.js @@ -604,9 +604,10 @@ Socket.prototype.__defineGetter__('localPort', function() { Socket.prototype.write = function(chunk, encoding, cb) { + 'use strict'; if (!util.isString(chunk) && !util.isBuffer(chunk)) throw new TypeError('invalid data'); - return stream.Duplex.prototype.write.call(this, chunk, encoding, cb); + return stream.Duplex.prototype.write.apply(this, arguments); };