Fix for integer.c possible uses of mp_int input with DP NULL.

This commit is contained in:
David Garske
2022-04-22 09:15:52 -07:00
parent ea2841fa7a
commit 74cd2fd910

View File

@@ -4378,6 +4378,10 @@ int mp_add_d (mp_int* a, mp_digit b, mp_int* c) // NOLINT(misc-no-recursion)
/* destination alias */
tmpc = c->dp;
if (tmpa == NULL || tmpc == NULL) {
return MP_MEM;
}
/* if a is positive */
if (a->sign == MP_ZPOS) {
/* add digit, after this we're propagating
@@ -4462,6 +4466,10 @@ int mp_sub_d (mp_int * a, mp_digit b, mp_int * c) // NOLINT(misc-no-recursion)
tmpa = a->dp;
tmpc = c->dp;
if (tmpa == NULL || tmpc == NULL) {
return MP_MEM;
}
/* if a <= b simply fix the single digit */
if ((a->used == 1 && a->dp[0] <= b) || a->used == 0) {
if (a->used == 1) {