@@ -399,8 +399,8 @@ Buffer.copyBytesFrom = function copyBytesFrom(view, offset, length) {
399399
400400 if ( end <= start ) return new FastBuffer ( ) ;
401401
402- const byteLength = TypedArrayPrototypeGetByteLength ( view ) ;
403- const elementSize = byteLength / viewLength ;
402+ const viewByteLength = TypedArrayPrototypeGetByteLength ( view ) ;
403+ const elementSize = viewByteLength / viewLength ;
404404 const srcByteOffset = TypedArrayPrototypeGetByteOffset ( view ) +
405405 start * elementSize ;
406406 const srcByteLength = ( end - start ) * elementSize ;
@@ -1171,7 +1171,7 @@ function _fill(buf, value, offset, end, encoding) {
11711171}
11721172
11731173Buffer . prototype . write = function write ( string , offset , length , encoding ) {
1174- const bufferLength = this . length ;
1174+ const bufferLength = TypedArrayPrototypeGetLength ( this ) ;
11751175 // Buffer#write(string);
11761176 if ( offset === undefined ) {
11771177 return utf8Write ( this , string , 0 , bufferLength ) ;
@@ -1212,10 +1212,10 @@ Buffer.prototype.write = function write(string, offset, length, encoding) {
12121212} ;
12131213
12141214Buffer . prototype . toJSON = function toJSON ( ) {
1215- const len = this . length ;
1216- if ( len > 0 ) {
1217- const data = new Array ( len ) ;
1218- for ( let i = 0 ; i < len ; ++ i )
1215+ const bufferLength = TypedArrayPrototypeGetLength ( this ) ;
1216+ if ( bufferLength > 0 ) {
1217+ const data = new Array ( bufferLength ) ;
1218+ for ( let i = 0 ; i < bufferLength ; ++ i )
12191219 data [ i ] = this [ i ] ;
12201220 return { type : 'Buffer' , data } ;
12211221 }
0 commit comments