]> zoso.dev Git - buffer.git/commitdiff
detect more invalid arraybuffers
authorFeross Aboukhadijeh <feross@feross.org>
Sat, 9 Jan 2016 14:26:39 +0000 (15:26 +0100)
committerFeross Aboukhadijeh <feross@feross.org>
Sat, 9 Jan 2016 14:26:39 +0000 (15:26 +0100)
index.js

index 33f07b4b58a7566a68264eab4773f5fd8c0fd300..79c1198dade20e4fc96142a5c72f568e7018e88d 100644 (file)
--- a/index.js
+++ b/index.js
@@ -183,9 +183,10 @@ function fromTypedArray (that, array) {
 }
 
 function fromArrayBuffer (that, array) {
+  array.byteLength // this throws if `array` is not a valid ArrayBuffer
+
   if (Buffer.TYPED_ARRAY_SUPPORT) {
     // Return an augmented `Uint8Array` instance, for best performance
-    array.byteLength
     that = new Uint8Array(array)
     that.__proto__ = Buffer.prototype
   } else {