summaryrefslogtreecommitdiffstats
path: root/crypto/ec
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2016-08-06 22:24:44 +0900
committerMatt Caswell <matt@openssl.org>2016-08-22 15:10:03 +0100
commit0110a4703608430c2131237c6afcf932a28c27ff (patch)
treefe38e7ea9588bcf3affa6afac14b4c3692caed14 /crypto/ec
parent9ba6f347fedbe103a06c8fd303912b358eacb11c (diff)
Fix a memory leak in EC_GROUP_get_ecparameters()
The variable 'buffer', allocated by EC_POINT_point2buf(), isn't free'd on the success path. Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
Diffstat (limited to 'crypto/ec')
-rw-r--r--crypto/ec/ec_asn1.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/crypto/ec/ec_asn1.c b/crypto/ec/ec_asn1.c
index e911b2b2e2..4f4d1edf0e 100644
--- a/crypto/ec/ec_asn1.c
+++ b/crypto/ec/ec_asn1.c
@@ -512,13 +512,11 @@ ECPARAMETERS *EC_GROUP_get_ecparameters(const EC_GROUP *group,
goto err;
}
if (ret->base == NULL && (ret->base = ASN1_OCTET_STRING_new()) == NULL) {
+ OPENSSL_free(buffer);
ECerr(EC_F_EC_GROUP_GET_ECPARAMETERS, ERR_R_MALLOC_FAILURE);
goto err;
}
- if (!ASN1_OCTET_STRING_set(ret->base, buffer, len)) {
- ECerr(EC_F_EC_GROUP_GET_ECPARAMETERS, ERR_R_ASN1_LIB);
- goto err;
- }
+ ASN1_STRING_set0(ret->base, buffer, len);
/* set the order */
tmp = EC_GROUP_get0_order(group);
@@ -547,7 +545,6 @@ ECPARAMETERS *EC_GROUP_get_ecparameters(const EC_GROUP *group,
err:
if (params == NULL)
ECPARAMETERS_free(ret);
- OPENSSL_free(buffer);
return NULL;
}