Skip to content

Commit 99cc9fd

Browse files
real-or-randomtheStack
authored andcommitted
Don't rely on memset to set signed integers to 0
1 parent 97c57f4 commit 99cc9fd

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/ecmult_impl.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,17 @@ static int secp256k1_ecmult_wnaf(int *wnaf, int len, const secp256k1_scalar *a,
171171
VERIFY_CHECK(a != NULL);
172172
VERIFY_CHECK(2 <= w && w <= 31);
173173

174-
memset(wnaf, 0, len * sizeof(wnaf[0]));
174+
for (bit = 0; bit < len; bit++) {
175+
wnaf[bit] = 0;
176+
}
175177

176178
s = *a;
177179
if (secp256k1_scalar_get_bits_limb32(&s, 255, 1)) {
178180
secp256k1_scalar_negate(&s, &s);
179181
sign = -1;
180182
}
181183

184+
bit = 0;
182185
while (bit < len) {
183186
int now;
184187
int word;

0 commit comments

Comments
 (0)