Skip to content

Commit

Permalink
Don't rely on memset to set signed integers to 0
Browse files Browse the repository at this point in the history
  • Loading branch information
real-or-random authored and theStack committed Oct 25, 2024
1 parent 97c57f4 commit 99cc9fd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/ecmult_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,17 @@ 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;
}

s = *a;
if (secp256k1_scalar_get_bits_limb32(&s, 255, 1)) {
secp256k1_scalar_negate(&s, &s);
sign = -1;
}

bit = 0;
while (bit < len) {
int now;
int word;
Expand Down

0 comments on commit 99cc9fd

Please sign in to comment.