From: Feross Aboukhadijeh Date: Sat, 9 Jan 2016 14:26:39 +0000 (+0100) Subject: detect more invalid arraybuffers X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=d54259454047786091261341fe542e6502dc8215;p=buffer.git detect more invalid arraybuffers --- diff --git a/index.js b/index.js index 33f07b4..79c1198 100644 --- 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 {