# HG changeset patch # User Michael Johnson # Date 1606544782 21600 # Sat Nov 28 00:26:22 2020 -0600 # Node ID 90c6f2d5a313159caf19b319acbd77202e6b0bdf # Parent e16488eaeb6f488d4d13d6bc6e89cd26c4ba6b50 Fix arithmetic overflow exception when reading ChaCha position diff --git a/src/RandN/Rngs/ChaCha.cs b/src/RandN/Rngs/ChaCha.cs --- a/src/RandN/Rngs/ChaCha.cs +++ b/src/RandN/Rngs/ChaCha.cs @@ -37,7 +37,7 @@ // bits of the counter to the word index, so that it becomes 6 bits. get { - var block = (_blockBuffer.BlockCounter << 2) + (UInt64)(_blockBuffer.Index >> 4); + var block = unchecked((_blockBuffer.BlockCounter << 2) + (UInt64)(_blockBuffer.Index >> 4)); var word = (UInt32)(_blockBuffer.Index & 0b1111); return new Counter(block, word); }