handle the case when BN_new returns NULL

This commit is contained in:
Bodo Möller 2000-11-07 09:35:19 +00:00
parent 55b3c877c7
commit 58f0f52e67

View File

@ -458,12 +458,20 @@ BIGNUM *bn_dup_expand(const BIGNUM *b, int words)
if (a) if (a)
{ {
r = BN_new(); r = BN_new();
if (r)
{
r->top = b->top; r->top = b->top;
r->dmax = words; r->dmax = words;
r->neg = b->neg; r->neg = b->neg;
r->d = a; r->d = a;
} }
/* Otherwise, there was an error in allocation in else
{
/* r == NULL, BN_new failure */
OPENSSL_free(a);
}
}
/* If a == NULL, there was an error in allocation in
internal_bn_expand(), and NULL should be returned */ internal_bn_expand(), and NULL should be returned */
} }
else else