function SlowBuffer(length) {
length = length >>> 0;
- if (this.length > kMaxLength) {
+ if (length > kMaxLength) {
throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
'size: 0x' + kMaxLength.toString(16) + ' bytes');
}
var Buffer = require('buffer').Buffer;
var SlowBuffer = require('buffer').SlowBuffer;
+var smalloc = require('smalloc');
// counter to ensure unique value is always copied
var cntr = 0;
b.fill('ghijk');
for (var i = 0; i < 5; i++)
assert.notEqual(d[i], b[i]);
+
+
+assert.throws(function () {
+ new Buffer(smalloc.kMaxLength + 1);
+}, RangeError);
+
+assert.throws(function () {
+ new SlowBuffer(smalloc.kMaxLength + 1);
+}, RangeError);