@@ -240,7 +240,7 @@ function copyImpl(source, target, targetStart, sourceStart, sourceEnd) {
240240 return _copyActual ( source , target , targetStart , sourceStart , sourceEnd ) ;
241241}
242242
243- function _copyActual ( source , target , targetStart , sourceStart , sourceEnd ) {
243+ function _copyActual ( source , target , targetStart , sourceStart , sourceEnd , isUint8Copy = false ) {
244244 if ( sourceEnd - sourceStart > target . byteLength - targetStart )
245245 sourceEnd = sourceStart + target . byteLength - targetStart ;
246246
@@ -252,7 +252,7 @@ function _copyActual(source, target, targetStart, sourceStart, sourceEnd) {
252252 if ( nb <= 0 )
253253 return 0 ;
254254
255- if ( sourceStart === 0 && nb === sourceLen ) {
255+ if ( sourceStart === 0 && nb === sourceLen && ( isUint8Copy || isUint8Array ( target ) ) ) {
256256 TypedArrayPrototypeSet ( target , source , targetStart ) ;
257257 } else {
258258 _copy ( source , target , targetStart , sourceStart , nb ) ;
@@ -604,7 +604,7 @@ Buffer.concat = function concat(list, length) {
604604 throw new ERR_INVALID_ARG_TYPE (
605605 `list[${ i } ]` , [ 'Buffer' , 'Uint8Array' ] , list [ i ] ) ;
606606 }
607- pos += _copyActual ( buf , buffer , pos , 0 , buf . length ) ;
607+ pos += _copyActual ( buf , buffer , pos , 0 , buf . length , true ) ;
608608 }
609609
610610 // Note: `length` is always equal to `buffer.length` at this point
0 commit comments