From 01fa3f5a39c860bf1949625c413b3237919d9334 Mon Sep 17 00:00:00 2001 From: Bridge Law Date: Mon, 24 Dec 2018 14:41:35 +0800 Subject: [PATCH] Fixed AccessViolationException issue The second argument of Crc32 methods can not be dereferenced from a pointer directly. --- Crc32cSharp/src/Crc32cAlgorithm.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Crc32cSharp/src/Crc32cAlgorithm.cs b/Crc32cSharp/src/Crc32cAlgorithm.cs index b58453f..dc1a661 100644 --- a/Crc32cSharp/src/Crc32cAlgorithm.cs +++ b/Crc32cSharp/src/Crc32cAlgorithm.cs @@ -61,24 +61,30 @@ unsafe static Crc32cAlgorithm() { #if CON_X86 var puint = (uint*)buffer; + uint idata; while (count > 3) { - hashValue = Sse42.Crc32(hashValue, *(puint++)); + idata=*(puint++); + hashValue = Sse42.Crc32(hashValue, idata); count -= 4; } var pubyte = (byte*)puint; #else var pulong = (ulong*)buffer; + ulong ldata; while (count > 7) { - hashValue = (uint)Sse42.X64.Crc32(hashValue, *(pulong++)); + ldata=*(pulong++); + hashValue = (uint)Sse42.X64.Crc32(hashValue, ldata); count -= 8; } var pubyte = (byte*)pulong; #endif + byte bdata; while (count-- > 0) { - hashValue = Sse42.Crc32(hashValue, *(pubyte++)); + bdata=*(pubyte++); + hashValue = Sse42.Crc32(hashValue, bdata); } return reversed ? ~hashValue : hashValue; });