From 65a69ad83cd4abe805edff8881e3ecadeab643cb Mon Sep 17 00:00:00 2001 From: Sun Yimin Date: Tue, 11 Mar 2025 08:58:16 +0800 Subject: [PATCH] internal/bigmod: explicitly clear expanded limbs on reset #313 --- internal/bigmod/nat.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/bigmod/nat.go b/internal/bigmod/nat.go index 128a40c..c5cf054 100644 --- a/internal/bigmod/nat.go +++ b/internal/bigmod/nat.go @@ -96,7 +96,8 @@ func (x *Nat) reset(n int) *Nat { x.limbs = make([]uint, n) 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] return x }