mirror of https://github.com/lukechilds/node.git
Browse Source
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>v5.x
Trevor Norris
9 years ago
2 changed files with 33 additions and 5 deletions
@ -0,0 +1,19 @@ |
|||
'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'); |
|||
} |
Loading…
Reference in new issue