Skip to content

Commit 198cf25

Browse files
Don't rely on memset to set signed integers to 0
1 parent fe7e100 commit 198cf25

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
@@ -406,13 +406,16 @@ static int secp256k1_ecmult_wnaf(int *wnaf, int len, const secp256k1_scalar *a,
406406
VERIFY_CHECK(a != NULL);
407407
VERIFY_CHECK(2 <= w && w <= 31);
408408

409-
memset(wnaf, 0, len * sizeof(wnaf[0]));
409+
for (bit = 0; bit < len; bit++) {
410+
wnaf[bit] = 0;
411+
}
410412

411413
if (secp256k1_scalar_get_bits(&s, 255, 1)) {
412414
secp256k1_scalar_negate(&s, &s);
413415
sign = -1;
414416
}
415417

418+
bit = 0;
416419
while (bit < len) {
417420
int now;
418421
int word;

0 commit comments

Comments
 (0)