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);