From 68f63fe9ec2b8a7308cefa4a1ae1261cd6d1675f Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Thu, 10 May 2012 16:54:17 +0200 Subject: [PATCH] child_process: make copy of options arg Make a copy of the options object that the user passes in, we modify it. --- lib/child_process.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/child_process.js b/lib/child_process.js index fdea1440825..63a0856bf3b 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -172,10 +172,10 @@ exports.fork = function(modulePath /*, args, options*/) { var options, args, execArgv; if (Array.isArray(arguments[1])) { args = arguments[1]; - options = arguments[2] || {}; + options = util._extend({}, arguments[2]); } else { args = []; - options = arguments[1] || {}; + options = util._extend({}, arguments[1]); } // Prepare arguments for fork: @@ -264,15 +264,12 @@ exports.execFile = function(file /* args, options, callback */) { if (Array.isArray(arguments[1])) { args = arguments[1]; - if (typeof arguments[2] === 'object') optionArg = arguments[2]; + options = util._extend(options, arguments[2]); } else { args = []; - if (typeof arguments[1] === 'object') optionArg = arguments[1]; + options = util._extend(options, arguments[1]); } - // Merge optionArg into options - util._extend(options, optionArg); - var child = spawn(file, args, { cwd: options.cwd, env: options.env,