Scan-Build Fixes

1. Added a check to see if the "d" in sp_div() ended up with a negative used length. Return error if so.

To recreate:
    $ scan-build ./configure --enable-sp --enable-sp-asm --enable-sp-math
This commit is contained in:
John Safranek
2020-11-12 10:15:55 -08:00
parent e996a7d15b
commit 38867ae2bf

View File

@ -927,6 +927,9 @@ static int sp_div(sp_int* a, sp_int* d, sp_int* r, sp_int* rem)
d = sd;
}
if (d->used < 0)
err = MP_VAL;
tr->used = sa->used - d->used + 1;
sp_clear(tr);
tr->used = sa->used - d->used + 1;