diff --git a/src/node_child_process.cc b/src/node_child_process.cc index 4d14800986..87b5cfa914 100644 --- a/src/node_child_process.cc +++ b/src/node_child_process.cc @@ -167,7 +167,13 @@ Handle ChildProcess::Spawn(const Arguments& args) { if (args[4]->IsArray()) { // Set the custom file descriptor values (if any) for the child process Local custom_fds_handle = Local::Cast(args[4]); + int custom_fds_len = custom_fds_handle->Length(); + // Bound by 3. + if (custom_fds_len > 3) { + custom_fds_len = 3; + } + for (int i = 0; i < custom_fds_len; i++) { if (custom_fds_handle->Get(i)->IsUndefined()) continue; Local fd = custom_fds_handle->Get(i)->ToInteger(); diff --git a/test/simple/test-child-process-customfd-bounded.js b/test/simple/test-child-process-customfd-bounded.js new file mode 100644 index 0000000000..93d061b6bb --- /dev/null +++ b/test/simple/test-child-process-customfd-bounded.js @@ -0,0 +1,8 @@ +var common = require('../common'); +var bigish = Array(200); + +for (var i = 0, il = bigish.length; i < il; ++i) + bigish[i] = -1; + +common.spawnPwd({ customFds: bigish }); +