-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
buffer: don't set zero fill for zero-length buffer
The Uint8Array constructor doesn't hit the ArrayBuffer::Allocator() when length == 0. So in these cases don't set the kNoZeroFill flag, since it won't be reset. 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: #2930
- Loading branch information
1 parent
1fa0cb8
commit 088585a
Showing
2 changed files
with
33 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'); | ||
} |