Merge pull request #6133 from philljj/zd15662
Fix malloc of zero size in fast_s_mp_sqr and fast_s_mp_mul_digs.
This commit is contained in:
commit
950e0d100a
@ -3335,6 +3335,12 @@ int fast_s_mp_sqr (mp_int * a, mp_int * b)
|
||||
if (pa > (int)MP_WARRAY)
|
||||
return MP_RANGE; /* TAO range check */
|
||||
|
||||
if (pa == 0) {
|
||||
/* Nothing to do. Zero result and return. */
|
||||
mp_zero(b);
|
||||
return MP_OKAY;
|
||||
}
|
||||
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
W = (mp_digit*)XMALLOC(sizeof(mp_digit) * pa, NULL, DYNAMIC_TYPE_BIGINT);
|
||||
if (W == NULL)
|
||||
@ -3454,6 +3460,12 @@ int fast_s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
|
||||
if (pa > (int)MP_WARRAY)
|
||||
return MP_RANGE; /* TAO range check */
|
||||
|
||||
if (pa == 0) {
|
||||
/* Nothing to do. Zero result and return. */
|
||||
mp_zero(c);
|
||||
return MP_OKAY;
|
||||
}
|
||||
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
W = (mp_digit*)XMALLOC(sizeof(mp_digit) * pa, NULL, DYNAMIC_TYPE_BIGINT);
|
||||
if (W == NULL)
|
||||
|
Loading…
x
Reference in New Issue
Block a user