@@ -426,10 +426,10 @@ Object.defineProperty(Buffer.prototype, 'offset', {
426426} ) ;
427427
428428
429- function slowToString ( encoding , start , end ) {
429+ function slowToString ( buf , encoding , start , end ) {
430430 var loweredCase = false ;
431431
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
433433 // property of a typed array.
434434
435435 // This behaves neither like String nor Uint8Array in that we set start/end
@@ -438,13 +438,13 @@ function slowToString(encoding, start, end) {
438438 // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
439439 if ( start === undefined || start < 0 )
440440 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
442442 // coercion fail below.
443- if ( start > this . length )
443+ if ( start > buf . length )
444444 return '' ;
445445
446- if ( end === undefined || end > this . length )
447- end = this . length ;
446+ if ( end === undefined || end > buf . length )
447+ end = buf . length ;
448448
449449 if ( end <= 0 )
450450 return '' ;
@@ -461,27 +461,27 @@ function slowToString(encoding, start, end) {
461461 while ( true ) {
462462 switch ( encoding ) {
463463 case 'hex' :
464- return this . hexSlice ( start , end ) ;
464+ return buf . hexSlice ( start , end ) ;
465465
466466 case 'utf8' :
467467 case 'utf-8' :
468- return this . utf8Slice ( start , end ) ;
468+ return buf . utf8Slice ( start , end ) ;
469469
470470 case 'ascii' :
471- return this . asciiSlice ( start , end ) ;
471+ return buf . asciiSlice ( start , end ) ;
472472
473473 case 'latin1' :
474474 case 'binary' :
475- return this . latin1Slice ( start , end ) ;
475+ return buf . latin1Slice ( start , end ) ;
476476
477477 case 'base64' :
478- return this . base64Slice ( start , end ) ;
478+ return buf . base64Slice ( start , end ) ;
479479
480480 case 'ucs2' :
481481 case 'ucs-2' :
482482 case 'utf16le' :
483483 case 'utf-16le' :
484- return this . ucs2Slice ( start , end ) ;
484+ return buf . ucs2Slice ( start , end ) ;
485485
486486 default :
487487 if ( loweredCase )
@@ -498,7 +498,7 @@ Buffer.prototype.toString = function(encoding, start, end) {
498498 if ( arguments . length === 0 ) {
499499 result = this . utf8Slice ( 0 , this . length ) ;
500500 } else {
501- result = slowToString . call ( this , encoding , start , end ) ;
501+ result = slowToString ( this , encoding , start , end ) ;
502502 }
503503 if ( result === undefined )
504504 throw new Error ( '"toString()" failed' ) ;
0 commit comments