From 4a467ec955817e7a5136a70d23a849f7d137e879 Mon Sep 17 00:00:00 2001 From: Sewer Date: Wed, 20 Jul 2022 22:37:07 +0200 Subject: [PATCH] Fixed: Incorrect Read Compressed Header Size when >1 byte. --- Source/Reloaded.Messaging/Messages/HeaderReader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Reloaded.Messaging/Messages/HeaderReader.cs b/Source/Reloaded.Messaging/Messages/HeaderReader.cs index f1db778..e39d6e4 100644 --- a/Source/Reloaded.Messaging/Messages/HeaderReader.cs +++ b/Source/Reloaded.Messaging/Messages/HeaderReader.cs @@ -44,7 +44,7 @@ public static void ReadHeader(Span data, out sbyte messageType, out int si if ((messageType & CompressionFlag) == CompressionFlag) { - sizeAfterDecompression = Unsafe.AsRef(Unsafe.Add(ref MemoryMarshal.GetReference(data), 1)); + sizeAfterDecompression = Unsafe.ReadUnaligned(ref Unsafe.Add(ref MemoryMarshal.GetReference(data), 1)); messageType = (sbyte)(messageType ^ CompressionFlag); if (!BitConverter.IsLittleEndian) // Evaluated at JIT time. sizeAfterDecompression = BinaryPrimitives.ReverseEndianness(sizeAfterDecompression);