summaryrefslogtreecommitdiffstats
path: root/crypto/bn/bn_lib.c
diff options
context:
space:
mode:
authorBodo Möller <bodo@openssl.org>2000-11-07 09:35:19 +0000
committerBodo Möller <bodo@openssl.org>2000-11-07 09:35:19 +0000
commit58f0f52e67b5053fd4f768a38c2b50bd77c9329b (patch)
tree813a17f28e199d7c9a6ff21d8401809693ccb8b0 /crypto/bn/bn_lib.c
parent55b3c877c7ec6ba97c1421b34767f88a3c56b51f (diff)
handle the case when BN_new returns NULL
Diffstat (limited to 'crypto/bn/bn_lib.c')
-rw-r--r--crypto/bn/bn_lib.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/crypto/bn/bn_lib.c b/crypto/bn/bn_lib.c
index 3e4965d695..89a3267b4a 100644
--- a/crypto/bn/bn_lib.c
+++ b/crypto/bn/bn_lib.c
@@ -458,12 +458,20 @@ BIGNUM *bn_dup_expand(const BIGNUM *b, int words)
if (a)
{
r = BN_new();
- r->top = b->top;
- r->dmax = words;
- r->neg = b->neg;
- r->d = a;
+ if (r)
+ {
+ r->top = b->top;
+ r->dmax = words;
+ r->neg = b->neg;
+ r->d = a;
+ }
+ else
+ {
+ /* r == NULL, BN_new failure */
+ OPENSSL_free(a);
+ }
}
- /* Otherwise, there was an error in allocation in
+ /* If a == NULL, there was an error in allocation in
internal_bn_expand(), and NULL should be returned */
}
else