diff --git a/protocol/src/main/resources/php/ByteBuffer.php b/protocol/src/main/resources/php/ByteBuffer.php index 6067ab17..5481c09b 100644 --- a/protocol/src/main/resources/php/ByteBuffer.php +++ b/protocol/src/main/resources/php/ByteBuffer.php @@ -32,6 +32,7 @@ class ByteBuffer $this->writeInt($length); $this->writeOffset = $currentwriteIndex; } else { + // substr is deep clone $bytes = substr($this->buffer, $currentwriteIndex - $length, $length); $this->writeOffset = $beforewriteIndex; $this->writeInt($length); diff --git a/protocol/src/main/resources/python/ByteBuffer.py b/protocol/src/main/resources/python/ByteBuffer.py index 3f10b45b..5ebe7623 100644 --- a/protocol/src/main/resources/python/ByteBuffer.py +++ b/protocol/src/main/resources/python/ByteBuffer.py @@ -25,6 +25,7 @@ class ByteBuffer(): self.writeInt(length) self.setWriteOffset(currentWriteIndex) else: + # slice of bytearray is deep clone retainedByteBuf = self.buffer[(currentWriteIndex - length):currentWriteIndex] self.setWriteOffset(beforeWriteIndex) self.writeInt(length)