diff options
author | Oleksii Kharkov <oleksiykharkov@gmail.com> | 2022-08-12 15:40:34 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-12 15:40:34 +0300 |
commit | 0eccfe506044da8d1a1ca2ca3d4270d6c8e319d2 (patch) | |
tree | dfffd3f0856297c57da4a9dfabb3c53f9a92822b | |
parent | 10955cc19e09600aa935cf6eb99933bfabbc301b (diff) |
Bug with long & double is fixed.
There was a bug, which produced "System.OverflowException: Arithmetic operation resulted in an overflow".
-rw-r--r-- | src/MessagePack.UnityClient/Assets/Scripts/MessagePack/SafeBitConverter.cs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/SafeBitConverter.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/SafeBitConverter.cs index 7eb77a00..8bbc141a 100644 --- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/SafeBitConverter.cs +++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/SafeBitConverter.cs @@ -13,15 +13,15 @@ namespace MessagePack #if UNITY_ANDROID if (BitConverter.IsLittleEndian) { - int i1 = value[0] | (value[1] << 8) | (value[2] << 16) | (value[3] << 24); - int i2 = value[4] | (value[5] << 8) | (value[6] << 16) | (value[7] << 24); - return (uint)i1 | ((long)i2 << 32); + long i1 = value[0] | (value[1] << 8) | (value[2] << 16) | (value[3] << 24); + long i2 = value[4] | (value[5] << 8) | (value[6] << 16) | (value[7] << 24); + return i1 | (i2 << 32); } else { - int i1 = (value[0] << 24) | (value[1] << 16) | (value[2] << 8) | value[3]; - int i2 = (value[4] << 24) | (value[5] << 16) | (value[6] << 8) | value[7]; - return (uint)i2 | ((long)i1 << 32); + long i1 = (value[0] << 24) | (value[1] << 16) | (value[2] << 8) | value[3]; + long i2 = (value[4] << 24) | (value[5] << 16) | (value[6] << 8) | value[7]; + return i2 | (i1 << 32); } #else return MemoryMarshal.Cast<byte, long>(value)[0]; |