summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2018-01-13 00:30:28 -0500
committercjihrig <cjihrig@gmail.com>2018-01-17 09:05:52 -0500
commit1e802539b2811f5090281cfc8041f21120c2c3c6 (patch)
tree12c0556043623b1bf1dacf01731dc51641b91c34 /test
parentdb9c556f507ea2510a603ca526d6cd1e79cfac2d (diff)
downloadandroid-node-v8-1e802539b2811f5090281cfc8041f21120c2c3c6.tar.gz
android-node-v8-1e802539b2811f5090281cfc8041f21120c2c3c6.tar.bz2
android-node-v8-1e802539b2811f5090281cfc8041f21120c2c3c6.zip
buffer: throw when filling with empty buffers
Prior to this commit, Node would enter an infinite loop when attempting to fill a non-zero length buffer with a zero length buffer. This commit introduces a thrown exception in this scenario. PR-URL: https://github.com/nodejs/node/pull/18129 Fixes: https://github.com/nodejs/node/issues/18128 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-buffer-alloc.js7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/parallel/test-buffer-alloc.js b/test/parallel/test-buffer-alloc.js
index 97392ed51c..58792788d6 100644
--- a/test/parallel/test-buffer-alloc.js
+++ b/test/parallel/test-buffer-alloc.js
@@ -1024,3 +1024,10 @@ common.expectsError(() => {
code: 'ERR_INVALID_ARG_VALUE',
type: TypeError
});
+
+common.expectsError(() => {
+ Buffer.alloc(1, Buffer.alloc(0));
+}, {
+ code: 'ERR_INVALID_ARG_VALUE',
+ type: TypeError
+});