Fix: unsafe initializing Buffer
This commit is contained in:
parent
39e95b7ca7
commit
4d62116ab2
1 changed files with 3 additions and 7 deletions
|
@ -364,13 +364,9 @@ function _readlineSync(options) {
|
|||
return;
|
||||
}
|
||||
|
||||
// https://github.com/nodejs/node/issues/4660
|
||||
// https://github.com/nodejs/node/pull/4682
|
||||
if (Buffer.alloc) {
|
||||
buffer = Buffer.alloc((reqSize = options.keyIn ? 1 : options.bufferSize));
|
||||
} else {
|
||||
buffer = new Buffer((reqSize = options.keyIn ? 1 : options.bufferSize));
|
||||
}
|
||||
reqSize = options.keyIn ? 1 : options.bufferSize;
|
||||
// Check `allocUnsafe` to make sure of the new API.
|
||||
buffer = Buffer.allocUnsafe && Buffer.alloc ? Buffer.alloc(reqSize) : new Buffer(reqSize);
|
||||
|
||||
if (options.keyIn && options.limit) {
|
||||
limit = new RegExp('[^' + options.limit + ']',
|
||||
|
|
Loading…
Reference in a new issue