diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/buffer.js | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/buffer.js b/lib/buffer.js index c75dbc93a8..000c54b3a8 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -339,6 +339,9 @@ Buffer.prototype.write = function(string, offset, length, encoding) { } encoding = String(encoding || 'utf8').toLowerCase(); + if (string.length > 0 && (length < 0 || offset < 0)) + throw new RangeError('attempt to write beyond buffer bounds'); + var ret; switch (encoding) { case 'hex': |