summaryrefslogtreecommitdiffstats
path: root/crypto/bn/bn_x931p.c
diff options
context:
space:
mode:
authorAlessandro Ghedini <alessandro@ghedini.me>2015-10-08 14:38:57 +0200
committerRichard Levitte <levitte@openssl.org>2015-10-23 19:52:08 +0200
commit3f6c7691870d1cd2ad0e0c83638cef3f35a0b548 (patch)
treef0dae5a5fabb3b68e94d748ca49f4262411fad7a /crypto/bn/bn_x931p.c
parent8acaabec429b39f9436f6a88006384d72d292539 (diff)
Fix memory leaks and other mistakes on errors
Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'crypto/bn/bn_x931p.c')
-rw-r--r--crypto/bn/bn_x931p.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/crypto/bn/bn_x931p.c b/crypto/bn/bn_x931p.c
index 15ba41dce3..76ce6f67d2 100644
--- a/crypto/bn/bn_x931p.c
+++ b/crypto/bn/bn_x931p.c
@@ -214,14 +214,14 @@ int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx)
* exceeded.
*/
if (!BN_rand(Xp, nbits, 1, 0))
- return 0;
+ goto err;
BN_CTX_start(ctx);
t = BN_CTX_get(ctx);
for (i = 0; i < 1000; i++) {
if (!BN_rand(Xq, nbits, 1, 0))
- return 0;
+ goto err;
/* Check that |Xp - Xq| > 2^(nbits - 100) */
BN_sub(t, Xp, Xq);
if (BN_num_bits(t) > (nbits - 100))
@@ -235,6 +235,9 @@ int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx)
return 0;
+ err:
+ BN_CTX_end(ctx);
+ return 0;
}
/*