mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 10:47:28 +02:00
Sanity check NULL dereference.
This commit is contained in:
@ -2846,6 +2846,14 @@ int mp_set_bit (mp_int * a, int b)
|
|||||||
{
|
{
|
||||||
int i = b / DIGIT_BIT, res;
|
int i = b / DIGIT_BIT, res;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Require:
|
||||||
|
* bit index b >= 0
|
||||||
|
* a->alloc == a->used == 0 if a->dp == NULL
|
||||||
|
*/
|
||||||
|
if (b < 0 || (a->dp == NULL && (a->alloc != 0 || a->used != 0)))
|
||||||
|
return MP_VAL;
|
||||||
|
|
||||||
if (a->dp == NULL || a->used < (int)(i + 1)) {
|
if (a->dp == NULL || a->used < (int)(i + 1)) {
|
||||||
/* grow a to accommodate the single bit */
|
/* grow a to accommodate the single bit */
|
||||||
if ((res = mp_grow (a, i + 1)) != MP_OKAY) {
|
if ((res = mp_grow (a, i + 1)) != MP_OKAY) {
|
||||||
|
Reference in New Issue
Block a user