From f89256deea4ca98945ecfdd67b79ccb463ba4fcd Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Thu, 15 Feb 2018 21:56:28 -0800 Subject: [PATCH] more robust check for invalid arguments to copy() --- index.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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 -- 2.34.1