diff --git a/protocol/src/main/resources/ecmascript/buffer/ByteBuffer.mjs b/protocol/src/main/resources/ecmascript/buffer/ByteBuffer.mjs index 779879b0..690d0cda 100644 --- a/protocol/src/main/resources/ecmascript/buffer/ByteBuffer.mjs +++ b/protocol/src/main/resources/ecmascript/buffer/ByteBuffer.mjs @@ -64,6 +64,7 @@ class ByteBuffer { this.writeInt(length); this.setWriteOffset(currentWriteIndex); } else { + // ArrayBuffer slice is deep clone const retainedByteBuf = this.buffer.slice(currentWriteIndex - length, currentWriteIndex); this.setWriteOffset(beforeWriteIndex); this.writeInt(length); diff --git a/protocol/src/main/resources/javascript/buffer/ByteBuffer.js b/protocol/src/main/resources/javascript/buffer/ByteBuffer.js index 82b8079e..41622b12 100644 --- a/protocol/src/main/resources/javascript/buffer/ByteBuffer.js +++ b/protocol/src/main/resources/javascript/buffer/ByteBuffer.js @@ -64,6 +64,7 @@ const ByteBuffer = function() { this.writeInt(length); this.setWriteOffset(currentWriteIndex); } else { + // ArrayBuffer slice is deep clone const retainedByteBuf = this.buffer.slice(currentWriteIndex - length, currentWriteIndex); this.setWriteOffset(beforeWriteIndex); this.writeInt(length); diff --git a/protocol/src/main/resources/typescript/buffer/ByteBuffer.ts b/protocol/src/main/resources/typescript/buffer/ByteBuffer.ts index 5bcd181f..6a2e8cb3 100644 --- a/protocol/src/main/resources/typescript/buffer/ByteBuffer.ts +++ b/protocol/src/main/resources/typescript/buffer/ByteBuffer.ts @@ -73,6 +73,7 @@ class ByteBuffer implements IByteBuffer{ this.writeInt(length); this.setWriteOffset(currentWriteIndex); } else { + // ArrayBuffer slice is deep clone const retainedByteBuf = this.buffer.slice(currentWriteIndex - length, currentWriteIndex); this.setWriteOffset(beforeWriteIndex); this.writeInt(length);