Skip to content

Commit b808227

Browse files
Don't rely on memset to set signed integers to 0
1 parent c1a2b98 commit b808227

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,14 +406,17 @@ 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
s = *a;
412414
if (secp256k1_scalar_get_bits(&s, 255, 1)) {
413415
secp256k1_scalar_negate(&s, &s);
414416
sign = -1;
415417
}
416418

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

0 commit comments

Comments
 (0)