Browse Source

test: fix allocUnsafe uninitialized buffer check

Fixes parallel/test-buffer-bindingobj-no-zerofill to properly check
that buffers created with `Buffer.allocUnsafe()` are not zero-filled.

The test introduced in #11706 passes even if the buffer has been
zero-filled and fails if none of the buffer values are zero.

Refs: https://github.com/nodejs/node/pull/11706
PR-URL: https://github.com/nodejs/node/pull/12290
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
v6
Karl Cheng 8 years ago
committed by James M Snell
parent
commit
eb49d596b4
  1. 2
      test/parallel/test-buffer-bindingobj-no-zerofill.js

2
test/parallel/test-buffer-bindingobj-no-zerofill.js

@ -44,7 +44,7 @@ const monkeyPatchedBuffer = require('../../lib/buffer');
// possible that a segment of memory is already zeroed out, so try again and
// again until we succeed or we time out.
let uninitialized = buffer.Buffer.allocUnsafe(1024);
while (uninitialized.some((val) => val !== 0))
while (uninitialized.every((val) => val === 0))
uninitialized = buffer.Buffer.allocUnsafe(1024);
// On monkeypatched buffer, zeroFill property is undefined. allocUnsafe() should

Loading…
Cancel
Save