diff --git a/wolfcrypt/src/integer.c b/wolfcrypt/src/integer.c index a185ee295..a463cbdef 100644 --- a/wolfcrypt/src/integer.c +++ b/wolfcrypt/src/integer.c @@ -125,6 +125,10 @@ int mp_init (mp_int * a) { int i; + /* Safeguard against passing in a null pointer */ + if (a == NULL) + return MP_VAL; + /* allocate memory required and clear it */ a->dp = OPT_CAST(mp_digit) XMALLOC (sizeof (mp_digit) * MP_PREC, 0, DYNAMIC_TYPE_BIGINT); @@ -275,6 +279,10 @@ mp_copy (mp_int * a, mp_int * b) { int res, n; + /* Safeguard against passing in a null pointer */ + if (a == NULL || b == NULL) + return MP_VAL; + /* if dst == src do nothing */ if (a == b) { return MP_OKAY;