From 0f17dbf17368cb095dc5ebf9ccfa3107ef9f7cda Mon Sep 17 00:00:00 2001 From: thegamecracks <61257169+thegamecracks@users.noreply.github.com> Date: Wed, 11 Dec 2024 09:43:00 -0500 Subject: [PATCH] fix: ensure reader always returns a copy of bytes --- src/dumdum/protocol/reader.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/dumdum/protocol/reader.py b/src/dumdum/protocol/reader.py index 8ca8a6f..f565ec4 100644 --- a/src/dumdum/protocol/reader.py +++ b/src/dumdum/protocol/reader.py @@ -20,7 +20,9 @@ def read(self, n: int = -1) -> bytes: n = min(n, len(self.buffer)) start, self._index = self._index, self._index + n - return self.buffer[start : self._index] + + data = self.buffer[start : self._index] + return bytes(data) if isinstance(data, bytearray) else data def readexactly(self, n: int) -> bytes: if n < 0: