diff options
Diffstat (limited to 'ext/node/polyfills/internal/buffer.mjs')
-rw-r--r-- | ext/node/polyfills/internal/buffer.mjs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/ext/node/polyfills/internal/buffer.mjs b/ext/node/polyfills/internal/buffer.mjs index cd69a199f..4d50fe80f 100644 --- a/ext/node/polyfills/internal/buffer.mjs +++ b/ext/node/polyfills/internal/buffer.mjs @@ -1536,8 +1536,12 @@ Buffer.prototype.copy = function copy( sourceStart = 0; } else { sourceStart = toInteger(sourceStart, 0); - if (sourceStart < 0) { - throw new codes.ERR_OUT_OF_RANGE("sourceStart", ">= 0", sourceStart); + if (sourceStart < 0 || sourceStart > this.length) { + throw new codes.ERR_OUT_OF_RANGE( + "sourceStart", + `>= 0 && <= ${this.length}`, + sourceStart, + ); } if (sourceStart >= MAX_UINT32) { throw new codes.ERR_OUT_OF_RANGE( |