mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
math.big: fix internal subtract_align_last_byte_in_place overflow (#18413)
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
module big
|
||||
|
||||
import math
|
||||
import math.bits
|
||||
|
||||
// suppose operand_a bigger than operand_b and both not null.
|
||||
@ -96,7 +97,8 @@ fn subtract_align_last_byte_in_place(mut a []u32, b []u32) {
|
||||
mut new_carry := u32(0)
|
||||
offset := a.len - b.len
|
||||
for index := a.len - b.len; index < a.len; index++ {
|
||||
if a[index] < (b[index - offset] + carry) {
|
||||
if a[index] < (b[index - offset] + carry)
|
||||
|| (b[index - offset] == math.max_u32 && carry > 0) {
|
||||
new_carry = 1
|
||||
} else {
|
||||
new_carry = 0
|
||||
|
Reference in New Issue
Block a user