@@ -426,10 +426,10 @@ Object.defineProperty(Buffer.prototype, 'offset', {
426
426
} ) ;
427
427
428
428
429
- function slowToString ( encoding , start , end ) {
429
+ function slowToString ( buf , encoding , start , end ) {
430
430
var loweredCase = false ;
431
431
432
- // No need to verify that "this .length <= MAX_UINT32" since it's a read-only
432
+ // No need to verify that "buf .length <= MAX_UINT32" since it's a read-only
433
433
// property of a typed array.
434
434
435
435
// This behaves neither like String nor Uint8Array in that we set start/end
@@ -438,13 +438,13 @@ function slowToString(encoding, start, end) {
438
438
// Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
439
439
if ( start === undefined || start < 0 )
440
440
start = 0 ;
441
- // Return early if start > this .length. Done here to prevent potential uint32
441
+ // Return early if start > buf .length. Done here to prevent potential uint32
442
442
// coercion fail below.
443
- if ( start > this . length )
443
+ if ( start > buf . length )
444
444
return '' ;
445
445
446
- if ( end === undefined || end > this . length )
447
- end = this . length ;
446
+ if ( end === undefined || end > buf . length )
447
+ end = buf . length ;
448
448
449
449
if ( end <= 0 )
450
450
return '' ;
@@ -461,27 +461,27 @@ function slowToString(encoding, start, end) {
461
461
while ( true ) {
462
462
switch ( encoding ) {
463
463
case 'hex' :
464
- return this . hexSlice ( start , end ) ;
464
+ return buf . hexSlice ( start , end ) ;
465
465
466
466
case 'utf8' :
467
467
case 'utf-8' :
468
- return this . utf8Slice ( start , end ) ;
468
+ return buf . utf8Slice ( start , end ) ;
469
469
470
470
case 'ascii' :
471
- return this . asciiSlice ( start , end ) ;
471
+ return buf . asciiSlice ( start , end ) ;
472
472
473
473
case 'latin1' :
474
474
case 'binary' :
475
- return this . latin1Slice ( start , end ) ;
475
+ return buf . latin1Slice ( start , end ) ;
476
476
477
477
case 'base64' :
478
- return this . base64Slice ( start , end ) ;
478
+ return buf . base64Slice ( start , end ) ;
479
479
480
480
case 'ucs2' :
481
481
case 'ucs-2' :
482
482
case 'utf16le' :
483
483
case 'utf-16le' :
484
- return this . ucs2Slice ( start , end ) ;
484
+ return buf . ucs2Slice ( start , end ) ;
485
485
486
486
default :
487
487
if ( loweredCase )
@@ -498,7 +498,7 @@ Buffer.prototype.toString = function(encoding, start, end) {
498
498
if ( arguments . length === 0 ) {
499
499
result = this . utf8Slice ( 0 , this . length ) ;
500
500
} else {
501
- result = slowToString . call ( this , encoding , start , end ) ;
501
+ result = slowToString ( this , encoding , start , end ) ;
502
502
}
503
503
if ( result === undefined )
504
504
throw new Error ( '"toString()" failed' ) ;
0 commit comments