Skip to content

Commit ce64b61

Browse files
committed
Fixed potential CopyFrom issue when using non BitStream streams
1 parent 580d292 commit ce64b61

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

MLAPI/NetworkingManagerComponents/Binary/BitStream.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,11 +347,16 @@ public void CopyFrom(Stream s, int count = -1)
347347
if (s is BitStream b) Write(b.target, 0, count < 0 ? (int)b.Length : count);
348348
else
349349
{
350+
long currentPosition = s.Position;
351+
s.Position = 0;
352+
350353
int read;
351354
bool readToEnd = count < 0;
352355
while ((readToEnd || count-- > 0) && (read = s.ReadByte()) != -1)
353356
_WriteIntByte(read);
354357
UpdateLength();
358+
359+
s.Position = currentPosition;
355360
}
356361
}
357362

0 commit comments

Comments
 (0)