mirror of
https://github.com/nodejs/node.git
synced 2025-05-09 09:08:46 +00:00

Instantiating a Buffer of length zero would set the kNoZeroFill flag to true but never actually call ArrayBuffer::Allocator(). Which means the flag was never set back to false. The result was that the next allocation would unconditionally not be zero filled. Add test to ensure Uint8Array's are zero-filled after creating a Buffer of length zero. This test may falsely succeed, but will not falsely fail. Fix: https://github.com/nodejs/node/issues/2930 PR-URL: https://github.com/nodejs/node/pull/2931 Reviewed-By: Rod Vagg <rod@vagg.org>
20 lines
368 B
JavaScript
20 lines
368 B
JavaScript
'use strict';
|
|
|
|
require('../common');
|
|
const assert = require('assert');
|
|
|
|
|
|
function testUint8Array(ui) {
|
|
const length = ui.length;
|
|
for (let i = 0; i < length; i++)
|
|
if (ui[i] !== 0) return false;
|
|
return true;
|
|
}
|
|
|
|
|
|
for (let i = 0; i < 100; i++) {
|
|
new Buffer(0);
|
|
let ui = new Uint8Array(65);
|
|
assert.ok(testUint8Array(ui), 'Uint8Array is not zero-filled');
|
|
}
|