internal/bigmod: explicitly clear expanded limbs on reset #313

This commit is contained in:
Sun Yimin 2025-03-11 08:58:16 +08:00 committed by GitHub
parent 71b196a5ac
commit 65a69ad83c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -96,7 +96,8 @@ func (x *Nat) reset(n int) *Nat {
x.limbs = make([]uint, n) x.limbs = make([]uint, n)
return x return x
} }
clear(x.limbs) // Clear both the returned limbs and the previously used ones.
clear(x.limbs[:max(n, len(x.limbs))])
x.limbs = x.limbs[:n] x.limbs = x.limbs[:n]
return x return x
} }