From 198cf2539950bb8d5421a2b30f9f8d8998e9301e Mon Sep 17 00:00:00 2001 From: Tim Ruffing Date: Sat, 8 Jun 2019 13:21:52 +0200 Subject: [PATCH] Don't rely on memset to set signed integers to 0 --- src/ecmult_impl.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ecmult_impl.h b/src/ecmult_impl.h index f27639098c..3bad0e4eec 100644 --- a/src/ecmult_impl.h +++ b/src/ecmult_impl.h @@ -406,13 +406,16 @@ static int secp256k1_ecmult_wnaf(int *wnaf, int len, const secp256k1_scalar *a, VERIFY_CHECK(a != NULL); VERIFY_CHECK(2 <= w && w <= 31); - memset(wnaf, 0, len * sizeof(wnaf[0])); + for (bit = 0; bit < len; bit++) { + wnaf[bit] = 0; + } if (secp256k1_scalar_get_bits(&s, 255, 1)) { secp256k1_scalar_negate(&s, &s); sign = -1; } + bit = 0; while (bit < len) { int now; int word;