Skip to content

Commit 9a9d57d

Browse files
committed
e{12}.c: tolerate NULL for |scalar| if |nbits| is 0.
By Guido Vranken's suggestion.
1 parent 2cee290 commit 9a9d57d

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/e1.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,10 @@ void blst_p1_mult(POINTonE1 *out, const POINTonE1 *a,
481481
const byte *scalar, size_t nbits)
482482
{
483483
if (nbits < 192) {
484-
POINTonE1_mult_w4(out, a, scalar, nbits);
484+
if (nbits)
485+
POINTonE1_mult_w4(out, a, scalar, nbits);
486+
else
487+
vec_zero(out, sizeof(*out));
485488
} else if (nbits <= 256) {
486489
union { vec256 l; pow256 s; } val;
487490
size_t i, j, top, mask = (size_t)0 - 1;

src/e2.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,10 @@ void blst_p2_mult(POINTonE2 *out, const POINTonE2 *a,
559559
const byte *scalar, size_t nbits)
560560
{
561561
if (nbits < 160) {
562-
POINTonE2_mult_w4(out, a, scalar, nbits);
562+
if (nbits)
563+
POINTonE2_mult_w4(out, a, scalar, nbits);
564+
else
565+
vec_zero(out, sizeof(*out));
563566
} else if (nbits <= 256) {
564567
union { vec256 l; pow256 s; } val;
565568
size_t i, j, top, mask = (size_t)0 - 1;

0 commit comments

Comments
 (0)