diff options
author | Bodo Möller <bodo@openssl.org> | 2000-11-07 09:39:51 +0000 |
---|---|---|
committer | Bodo Möller <bodo@openssl.org> | 2000-11-07 09:39:51 +0000 |
commit | e0bf5c11ea389fa3bacecdf4f3f9d22835a7508a (patch) | |
tree | 5cc1e232cd088284cb3ae7c0e36a2d2cac40e9d9 | |
parent | 58f0f52e67b5053fd4f768a38c2b50bd77c9329b (diff) | |
download | openssl-e0bf5c11ea389fa3bacecdf4f3f9d22835a7508a.tar.gz |
Handle BN_copy failure after successful BN_new.
-rw-r--r-- | crypto/bn/bn_lib.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/crypto/bn/bn_lib.c b/crypto/bn/bn_lib.c index 89a3267b4a..0ad62652f6 100644 --- a/crypto/bn/bn_lib.c +++ b/crypto/bn/bn_lib.c @@ -507,15 +507,19 @@ BIGNUM *bn_expand2(BIGNUM *b, int words) BIGNUM *BN_dup(const BIGNUM *a) { - BIGNUM *r; + BIGNUM *r, *t; if (a == NULL) return NULL; bn_check_top(a); - r=BN_new(); - if (r == NULL) return(NULL); - return((BIGNUM *)BN_copy(r,a)); + t = BN_new(); + if (t == NULL) return(NULL); + r = BN_copy(t, a); + /* now r == t || r == NULL */ + if (r == NULL) + BN_free(t); + return r; } BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b) |