summaryrefslogtreecommitdiffstats
path: root/lib/libssl/src/crypto/ec/ec_lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libssl/src/crypto/ec/ec_lib.c')
-rw-r--r--lib/libssl/src/crypto/ec/ec_lib.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/lib/libssl/src/crypto/ec/ec_lib.c b/lib/libssl/src/crypto/ec/ec_lib.c
index 47ccc614d1a..8cf0f2241ee 100644
--- a/lib/libssl/src/crypto/ec/ec_lib.c
+++ b/lib/libssl/src/crypto/ec/ec_lib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ec_lib.c,v 1.15 2014/07/12 16:03:37 miod Exp $ */
+/* $OpenBSD: ec_lib.c,v 1.16 2015/02/09 15:49:22 jsing Exp $ */
/*
* Originally written by Bodo Moeller for the OpenSSL project.
*/
@@ -497,18 +497,19 @@ EC_GROUP_cmp(const EC_GROUP * a, const EC_GROUP * b, BN_CTX * ctx)
return -1;
BN_CTX_start(ctx);
- a1 = BN_CTX_get(ctx);
- a2 = BN_CTX_get(ctx);
- a3 = BN_CTX_get(ctx);
- b1 = BN_CTX_get(ctx);
- b2 = BN_CTX_get(ctx);
- b3 = BN_CTX_get(ctx);
- if (!b3) {
- BN_CTX_end(ctx);
- if (ctx_new)
- BN_CTX_free(ctx);
- return -1;
- }
+ if ((a1 = BN_CTX_get(ctx)) == NULL)
+ goto err;
+ if ((a2 = BN_CTX_get(ctx)) == NULL)
+ goto err;
+ if ((a3 = BN_CTX_get(ctx)) == NULL)
+ goto err;
+ if ((b1 = BN_CTX_get(ctx)) == NULL)
+ goto err;
+ if ((b2 = BN_CTX_get(ctx)) == NULL)
+ goto err;
+ if ((b3 = BN_CTX_get(ctx)) == NULL)
+ goto err;
+
/*
* XXX This approach assumes that the external representation of
* curves over the same field type is the same.
@@ -544,6 +545,12 @@ EC_GROUP_cmp(const EC_GROUP * a, const EC_GROUP * b, BN_CTX * ctx)
BN_CTX_free(ctx);
return r;
+
+err:
+ BN_CTX_end(ctx);
+ if (ctx_new)
+ BN_CTX_free(ctx);
+ return -1;
}