Skip to content

Commit

Permalink
Use memorystream overload with offset
Browse files Browse the repository at this point in the history
  • Loading branch information
xPaw committed Nov 14, 2021
1 parent 1214637 commit d07a59e
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions SteamKit2/SteamKit2/Base/ClientMsg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,9 @@ public ClientMsgProtobuf( IPacketMsg msg )

Header = packetMsg.Header;

using MemoryStream ms = new MemoryStream( packetMsg.GetData() );
ms.Seek( packetMsg.BodyOffset, SeekOrigin.Begin );
var data = packetMsg.GetData();
var offset = (int)packetMsg.BodyOffset;
using MemoryStream ms = new MemoryStream( data, offset, data.Length - offset );

Body = Serializer.Deserialize<TBody>( ms );

Expand Down Expand Up @@ -353,8 +354,9 @@ public ClientMsg( IPacketMsg msg )

Header = packetMsg.Header;

using MemoryStream ms = new MemoryStream( packetMsg.GetData() );
ms.Seek( packetMsg.BodyOffset, SeekOrigin.Begin );
var data = packetMsg.GetData();
var offset = (int)packetMsg.BodyOffset;
using MemoryStream ms = new MemoryStream( data, offset, data.Length - offset );

Body.Deserialize( ms );

Expand Down Expand Up @@ -506,8 +508,9 @@ public Msg( IPacketMsg msg )

Header = packetMsg.Header;

using MemoryStream ms = new MemoryStream( packetMsg.GetData() );
ms.Seek( packetMsg.BodyOffset, SeekOrigin.Begin );
var data = packetMsg.GetData();
var offset = (int)packetMsg.BodyOffset;
using MemoryStream ms = new MemoryStream( data, offset, data.Length - offset );

Body.Deserialize( ms );

Expand Down

0 comments on commit d07a59e

Please sign in to comment.