Commit 2c3939c
child_process: use stdio.fd even if it is 0
Previously, in _validateStdio we were using stdio.fd || stdio. If
stdio.fd was falsy (or 0 in the case of stdin), then the entire stdio
object would be passed which could cause a crash.
Fixes: #2721
PR-URL: #2727
Reviewed-By: silverwind - Roman Reiss <me@silverwind.io>
Reviewed-By: cjihrig - Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: indutny - Fedor Indutny <fedor.indutny@gmail.com>1 parent 03f900a commit 2c3939c
File tree
2 files changed
+13
-1
lines changed- lib/internal
- test/parallel
2 files changed
+13
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
766 | 766 | | |
767 | 767 | | |
768 | 768 | | |
769 | | - | |
| 769 | + | |
770 | 770 | | |
771 | 771 | | |
772 | 772 | | |
| |||
@@ -28,3 +28,15 @@ var stdio2 = ['ipc', 'ipc', 'ipc'];2828assert.throws(function() {2929 _validateStdio(stdio2, true);3030}, /You cannot use IPC with synchronous forks/);31+32+const stdio3 = [process.stdin, process.stdout, process.stderr];33+var result = _validateStdio(stdio3, false);34+assert.deepStrictEqual(result, {35+ stdio: [36+ { type: 'fd', fd: 0 },37+ { type: 'fd', fd: 1 },38+ { type: 'fd', fd: 2 }39+ ],40+ ipc: undefined,41+ ipcFd: undefined42+});
0 commit comments