Logo
Explore Help
Sign In
1berry/nodejs
1
0
Fork 0
You've already forked nodejs
Code Issues Packages Projects Releases Wiki Activity
nodejs/test/parallel/test-buffer-zero-fill-reset.js

20 lines
368 B
JavaScript
Raw Normal View History

buffer: don't set zero fill for zero-length buffer 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>
2015-09-17 10:48:16 -06:00
'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');
}
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.23.8 Page: 609ms Template: 18ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API