@@ -433,10 +433,10 @@ Object.defineProperty(Buffer.prototype, 'offset', {
433
433
} ) ;
434
434
435
435
436
- function slowToString ( encoding , start , end ) {
436
+ function slowToString ( buf , encoding , start , end ) {
437
437
var loweredCase = false ;
438
438
439
- // No need to verify that "this .length <= MAX_UINT32" since it's a read-only
439
+ // No need to verify that "buf .length <= MAX_UINT32" since it's a read-only
440
440
// property of a typed array.
441
441
442
442
// This behaves neither like String nor Uint8Array in that we set start/end
@@ -445,13 +445,13 @@ function slowToString(encoding, start, end) {
445
445
// Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
446
446
if ( start === undefined || start < 0 )
447
447
start = 0 ;
448
- // Return early if start > this .length. Done here to prevent potential uint32
448
+ // Return early if start > buf .length. Done here to prevent potential uint32
449
449
// coercion fail below.
450
- if ( start > this . length )
450
+ if ( start > buf . length )
451
451
return '' ;
452
452
453
- if ( end === undefined || end > this . length )
454
- end = this . length ;
453
+ if ( end === undefined || end > buf . length )
454
+ end = buf . length ;
455
455
456
456
if ( end <= 0 )
457
457
return '' ;
@@ -468,27 +468,27 @@ function slowToString(encoding, start, end) {
468
468
while ( true ) {
469
469
switch ( encoding ) {
470
470
case 'hex' :
471
- return this . hexSlice ( start , end ) ;
471
+ return buf . hexSlice ( start , end ) ;
472
472
473
473
case 'utf8' :
474
474
case 'utf-8' :
475
- return this . utf8Slice ( start , end ) ;
475
+ return buf . utf8Slice ( start , end ) ;
476
476
477
477
case 'ascii' :
478
- return this . asciiSlice ( start , end ) ;
478
+ return buf . asciiSlice ( start , end ) ;
479
479
480
480
case 'latin1' :
481
481
case 'binary' :
482
- return this . latin1Slice ( start , end ) ;
482
+ return buf . latin1Slice ( start , end ) ;
483
483
484
484
case 'base64' :
485
- return this . base64Slice ( start , end ) ;
485
+ return buf . base64Slice ( start , end ) ;
486
486
487
487
case 'ucs2' :
488
488
case 'ucs-2' :
489
489
case 'utf16le' :
490
490
case 'utf-16le' :
491
- return this . ucs2Slice ( start , end ) ;
491
+ return buf . ucs2Slice ( start , end ) ;
492
492
493
493
default :
494
494
if ( loweredCase )
@@ -508,7 +508,7 @@ Buffer.prototype.toString = function(encoding, start, end) {
508
508
if ( arguments . length === 0 ) {
509
509
result = this . utf8Slice ( 0 , this . length ) ;
510
510
} else {
511
- result = slowToString . call ( this , encoding , start , end ) ;
511
+ result = slowToString ( this , encoding , start , end ) ;
512
512
}
513
513
if ( result === undefined )
514
514
throw new Error ( '"toString()" failed' ) ;
0 commit comments