child_process: fix exec set stdout.setEncoding
cp.exec decide to use _stdout
(_stdout is string) or
Buffer.concat(_stdout)
(_stdout is buffer array) by options.encoding.
but std(out|err) encoding can be changed. If encoding is changed to
not null, _stdout
will become string, and Buffer.concat(_stdout)
will throw TypeError. This patch will fix it, use
options.encoding and std(out|err)._readableState.encoding
.
Fixes: https://github.com/nodejs/node/issues/18969
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
commit message follows commit guidelines
Affected core subsystem(s)
child_process