@@ -458,6 +458,11 @@ function execFile(file, args, options, callback) {
458458 child.stdout.setEncoding(encoding);
459459
460460 child.stdout.on('data', function onChildStdout(chunk) {
461+ // Do not need to count the length
462+ if (options.maxBuffer === Infinity) {
463+ ArrayPrototypePush(_stdout, chunk);
464+ return;
465+ }
461466 const encoding = child.stdout.readableEncoding;
462467 const length = encoding ?
463468 Buffer.byteLength(chunk, encoding) :
@@ -483,6 +488,11 @@ function execFile(file, args, options, callback) {
483488 child.stderr.setEncoding(encoding);
484489
485490 child.stderr.on('data', function onChildStderr(chunk) {
491+ // Do not need to count the length
492+ if (options.maxBuffer === Infinity) {
493+ ArrayPrototypePush(_stderr, chunk);
494+ return;
495+ }
486496 const encoding = child.stderr.readableEncoding;
487497 const length = encoding ?
488498 Buffer.byteLength(chunk, encoding) :
@@ -497,7 +507,7 @@ function execFile(file, args, options, callback) {
497507 ex = new ERR_CHILD_PROCESS_STDIO_MAXBUFFER('stderr');
498508 kill();
499509 } else {
500- _stderr.push( chunk);
510+ ArrayPrototypePush(_stderr, chunk);
501511 }
502512 });
503513 }
0 commit comments