safeguards to avoid de-referencing a null pointer

This commit is contained in:
kaleb-himes
2016-01-06 10:12:52 -07:00
parent 251550ea62
commit 38392ce56a

View File

@ -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;