Fix: unsafe initializing Buffer

This commit is contained in:
anseki 2017-03-18 22:47:19 +09:00
parent 39e95b7ca7
commit 4d62116ab2

View file

@ -364,13 +364,9 @@ function _readlineSync(options) {
return; return;
} }
// https://github.com/nodejs/node/issues/4660 reqSize = options.keyIn ? 1 : options.bufferSize;
// https://github.com/nodejs/node/pull/4682 // Check `allocUnsafe` to make sure of the new API.
if (Buffer.alloc) { buffer = Buffer.allocUnsafe && Buffer.alloc ? Buffer.alloc(reqSize) : new Buffer(reqSize);
buffer = Buffer.alloc((reqSize = options.keyIn ? 1 : options.bufferSize));
} else {
buffer = new Buffer((reqSize = options.keyIn ? 1 : options.bufferSize));
}
if (options.keyIn && options.limit) { if (options.keyIn && options.limit) {
limit = new RegExp('[^' + options.limit + ']', limit = new RegExp('[^' + options.limit + ']',