mirror of https://github.com/nodejs/node.git
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.pull/41362/head
parent
2769d97e67
commit
fa89cf545c
|
@ -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 += ' ... ';
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue