diff options
author | Trevor Norris <trev.norris@gmail.com> | 2015-07-16 15:19:01 -0600 |
---|---|---|
committer | Rod Vagg <rod@vagg.org> | 2015-08-04 11:56:17 -0700 |
commit | 60a974d200b8eeab2a92e0a68a8b2a98899f8e6d (patch) | |
tree | fb4c123e7b7f1ae8eb22411eb910e167a4018c37 /lib | |
parent | 2ba8b236612c1cc9ea69dd82508c981c8a3937e0 (diff) | |
download | android-node-v8-60a974d200b8eeab2a92e0a68a8b2a98899f8e6d.tar.gz android-node-v8-60a974d200b8eeab2a92e0a68a8b2a98899f8e6d.tar.bz2 android-node-v8-60a974d200b8eeab2a92e0a68a8b2a98899f8e6d.zip |
buffer: fix missing null/undefined check
The new implementation of Buffer missed the check for null/undefined as
the first argument to new Buffer(). Reintroduce the check and add test.
Fix: e8734c0 "buffer: implement Uint8Array backed Buffer"
Fix: https://github.com/nodejs/io.js/issues/2194
PR-URL: https://github.com/nodejs/io.js/pull/2195
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/buffer.js | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/buffer.js b/lib/buffer.js index b9fe5bfb84..403c344bdb 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -105,6 +105,10 @@ function fromObject(obj) { return b; } + if (obj == null) { + throw new TypeError('must start with number, buffer, array or string'); + } + if (obj instanceof ArrayBuffer) { return binding.createFromArrayBuffer(obj); } |