summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorVladimir Kurchatkin <vladimir.kurchatkin@gmail.com>2016-04-02 02:39:25 +0300
committerJames M Snell <jasnell@gmail.com>2016-04-01 17:27:25 -0700
commit0dcb026db3386a37aa9a63959bbeb6d124f3e601 (patch)
tree8e78b402d9416a851b7c51e3550eb11e85546eb4 /test
parent0928584444ac6edf1ead0b93c9d05b1124183702 (diff)
downloadandroid-node-v8-0dcb026db3386a37aa9a63959bbeb6d124f3e601.tar.gz
android-node-v8-0dcb026db3386a37aa9a63959bbeb6d124f3e601.tar.bz2
android-node-v8-0dcb026db3386a37aa9a63959bbeb6d124f3e601.zip
buffer: don't set `kNoZeroFill` flag in allocUnsafe
If `kNoZeroFill` is set here, it won't be reset in case of pooled allocation. In case of "slow" allocation it will be set later anyway. Fixes: https://github.com/nodejs/node/issues/6006 PR-URL: https://github.com/nodejs/node/pull/6007 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-buffer-safe-unsafe.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/test/parallel/test-buffer-safe-unsafe.js b/test/parallel/test-buffer-safe-unsafe.js
index 6646f76056..9f8b6b7410 100644
--- a/test/parallel/test-buffer-safe-unsafe.js
+++ b/test/parallel/test-buffer-safe-unsafe.js
@@ -7,8 +7,18 @@ const safe = Buffer.alloc(10);
function isZeroFilled(buf) {
for (let n = 0; n < buf.length; n++)
- if (buf[n] > 0) return false;
+ if (buf[n] !== 0) return false;
return true;
}
assert(isZeroFilled(safe));
+
+// Test that unsafe allocations doesn't affect subsequent safe allocations
+Buffer.allocUnsafe(10);
+assert(isZeroFilled(new Float64Array(10)));
+
+new Buffer(10);
+assert(isZeroFilled(new Float64Array(10)));
+
+Buffer.allocUnsafe(10);
+assert(isZeroFilled(Buffer.alloc(10)));