Don't access buffer data before initializing it.

Prevents valgrind from complaining and still tests that buffer data is
treated as unsigned.
pull/22966/head
Tom Hughes 2010-12-20 11:15:20 -06:00 committed by Ryan Dahl
parent b38f4712c4
commit 0d58353d66
1 changed files with 3 additions and 1 deletions

View File

@ -8,8 +8,10 @@ var b = Buffer(1024); // safe constructor
console.log('b.length == ' + b.length);
assert.strictEqual(1024, b.length);
b[0] = -1;
assert.equal(b[0], 255);
for (var i = 0; i < 1024; i++) {
assert.ok(b[i] >= 0);
b[i] = i % 256;
}