parent
a263abaa81
commit
e5346932bc
@ -58,8 +58,10 @@ function Buffer(subject, encoding) {
|
||||
else
|
||||
throw new TypeError('must start with number, buffer, array or string');
|
||||
|
||||
if (this.length > kMaxLength)
|
||||
throw new RangeError('length > kMaxLength');
|
||||
if (this.length > kMaxLength) {
|
||||
throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
|
||||
'size: 0x' + kMaxLength.toString(16) + ' bytes');
|
||||
}
|
||||
|
||||
if (this.length < Buffer.poolSize / 2 && this.length > 0) {
|
||||
if (this.length > poolSize - poolOffset)
|
||||
@ -92,8 +94,10 @@ function Buffer(subject, encoding) {
|
||||
|
||||
function SlowBuffer(length) {
|
||||
length = length >>> 0;
|
||||
if (length > kMaxLength)
|
||||
throw new RangeError('length > kMaxLength');
|
||||
if (this.length > kMaxLength) {
|
||||
throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
|
||||
'size: 0x' + kMaxLength.toString(16) + ' bytes');
|
||||
}
|
||||
var b = new NativeBuffer(length);
|
||||
alloc(b, length);
|
||||
return b;
|
||||
|
@ -38,6 +38,7 @@ var Readable = Stream.Readable;
|
||||
var Writable = Stream.Writable;
|
||||
|
||||
var kMinPoolSpace = 128;
|
||||
var kMaxLength = require('smalloc').kMaxLength;
|
||||
|
||||
var O_APPEND = constants.O_APPEND || 0;
|
||||
var O_CREAT = constants.O_CREAT || 0;
|
||||
@ -204,6 +205,10 @@ fs.readFile = function(path, options, callback_) {
|
||||
return read();
|
||||
}
|
||||
|
||||
if (size > kMaxLength)
|
||||
throw new RangeError('File size is greater than possible Buffer: ' +
|
||||
'0x3FFFFFFF bytes');
|
||||
|
||||
buffer = new Buffer(size);
|
||||
read();
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user