Fix undefined behavior when shift amount is 64

master
Timon Kruiper 2020-04-01 20:40:13 +02:00
parent d9cf779b47
commit ae6965a4e7
1 changed files with 1 additions and 1 deletions

View File

@ -1430,7 +1430,7 @@ void bigint_shr(BigInt *dest, const BigInt *op1, const BigInt *op2) {
uint64_t digit = op1_digits[op_digit_index];
size_t dest_digit_index = op_digit_index - digit_shift_count;
digits[dest_digit_index] = carry | (digit >> leftover_shift_count);
carry = digit << (64 - leftover_shift_count);
carry = (leftover_shift_count != 0) ? (digit << (64 - leftover_shift_count)) : 0;
if (dest_digit_index == 0) { break; }
op_digit_index -= 1;