forked from wolfSSL/wolfssl
safeguards to avoid de-referencing a null pointer
This commit is contained in:
@ -125,6 +125,10 @@ int mp_init (mp_int * a)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
/* Safeguard against passing in a null pointer */
|
||||||
|
if (a == NULL)
|
||||||
|
return MP_VAL;
|
||||||
|
|
||||||
/* allocate memory required and clear it */
|
/* allocate memory required and clear it */
|
||||||
a->dp = OPT_CAST(mp_digit) XMALLOC (sizeof (mp_digit) * MP_PREC, 0,
|
a->dp = OPT_CAST(mp_digit) XMALLOC (sizeof (mp_digit) * MP_PREC, 0,
|
||||||
DYNAMIC_TYPE_BIGINT);
|
DYNAMIC_TYPE_BIGINT);
|
||||||
@ -275,6 +279,10 @@ mp_copy (mp_int * a, mp_int * b)
|
|||||||
{
|
{
|
||||||
int res, n;
|
int res, n;
|
||||||
|
|
||||||
|
/* Safeguard against passing in a null pointer */
|
||||||
|
if (a == NULL || b == NULL)
|
||||||
|
return MP_VAL;
|
||||||
|
|
||||||
/* if dst == src do nothing */
|
/* if dst == src do nothing */
|
||||||
if (a == b) {
|
if (a == b) {
|
||||||
return MP_OKAY;
|
return MP_OKAY;
|
||||||
|
Reference in New Issue
Block a user