From fa89cf545cad2ae6fc2ed15006b9c118cb9077d2 Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Wed, 21 Aug 2013 22:18:20 -0700 Subject: [PATCH] buffer: fix inspect throw if slice length too long All the Buffer#{ascii,hex,etc.}Slice() methods are intentionally strict to alert if a Buffer instance was attempting to be accessed out of bounds. Buffer#toString() is the more user friendly way of accessing the data, and will coerce values to their min/max on overflow. --- lib/buffer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/buffer.js b/lib/buffer.js index f6eb984..c626642 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -239,7 +239,7 @@ Buffer.prototype.inspect = function inspect() { var str = ''; var max = exports.INSPECT_MAX_BYTES; if (this.length > 0) { - str = this.hexSlice(0, max).match(/.{2}/g).join(' '); + str = this.toString('hex', 0, max).match(/.{2}/g).join(' '); if (this.length > max) str += ' ... '; } -- 2.7.4