Skip to content

Commit

Permalink
fix: ensure reader always returns a copy of bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
thegamecracks committed Dec 11, 2024
1 parent 45cf43e commit 0f17dbf
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/dumdum/protocol/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 0f17dbf

Please sign in to comment.