From: Feross Aboukhadijeh Date: Fri, 16 Feb 2018 05:56:28 +0000 (-0800) Subject: more robust check for invalid arguments to copy() X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=f89256deea4ca98945ecfdd67b79ccb463ba4fcd;p=buffer.git more robust check for invalid arguments to copy() --- diff --git a/index.js b/index.js index b2ace85..0e45b2a 100644 --- a/index.js +++ b/index.js @@ -1465,9 +1465,7 @@ Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) Buffer.prototype.copy = function copy (target, targetStart, start, end) { - if (target === undefined) { - throw new TypeError('argument should be a Buffer') - } + if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer') if (!start) start = 0 if (!end && end !== 0) end = this.length if (targetStart >= target.length) targetStart = target.length