buffer: fix typo in SlowBuffer

This commit is contained in:
Vladimir Kurchatkin 2014-03-08 18:52:51 +04:00 committed by Timothy J Fontaine
parent 68bfa91af7
commit e108ff4da7
2 changed files with 11 additions and 1 deletions

View File

@ -93,7 +93,7 @@ function Buffer(subject, encoding) {
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');
}

View File

@ -24,6 +24,7 @@ var assert = require('assert');
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;
@ -993,3 +994,12 @@ for (var i = 0; i < 5; i++)
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);