Skip to content

Commit

Permalink
Fixed AccessViolationException issue
Browse files Browse the repository at this point in the history
The second argument of Crc32 methods can not be dereferenced from a pointer directly.
  • Loading branch information
differentrain authored Dec 24, 2018
1 parent fd34229 commit 01fa3f5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Crc32cSharp/src/Crc32cAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down

0 comments on commit 01fa3f5

Please sign in to comment.