summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2019-09-09 20:26:16 +0000
committertb <>2019-09-09 20:26:16 +0000
commit9e3335ef7df1b42c52b5dfec776d879f4275e876 (patch)
treedf1a1e1b9aa809ccad887091a4921fa0ae7e8a7d /src
parent8c18a9af07ae60481c97eb03c3ed72a1d0bb44b5 (diff)
downloadopenbsd-9e3335ef7df1b42c52b5dfec776d879f4275e876.tar.gz
openbsd-9e3335ef7df1b42c52b5dfec776d879f4275e876.tar.bz2
openbsd-9e3335ef7df1b42c52b5dfec776d879f4275e876.zip
Plug memory leak in error paths. Found while comparing this file
with OpenSSL 1.1.1's version which contains a similar fix. ok jsing
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/ec/ec_ameth.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/lib/libcrypto/ec/ec_ameth.c b/src/lib/libcrypto/ec/ec_ameth.c
index ad7b03f739..2e73bdd2f6 100644
--- a/src/lib/libcrypto/ec/ec_ameth.c
+++ b/src/lib/libcrypto/ec/ec_ameth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_ameth.c,v 1.27 2019/09/09 17:56:00 jsing Exp $ */ 1/* $OpenBSD: ec_ameth.c,v 1.28 2019/09/09 20:26:16 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
@@ -143,6 +143,7 @@ eckey_pub_encode(X509_PUBKEY * pk, const EVP_PKEY * pkey)
143static EC_KEY * 143static EC_KEY *
144eckey_type2param(int ptype, const void *pval) 144eckey_type2param(int ptype, const void *pval)
145{ 145{
146 EC_GROUP *group = NULL;
146 EC_KEY *eckey = NULL; 147 EC_KEY *eckey = NULL;
147 148
148 if (ptype == V_ASN1_SEQUENCE) { 149 if (ptype == V_ASN1_SEQUENCE) {
@@ -158,7 +159,6 @@ eckey_type2param(int ptype, const void *pval)
158 } 159 }
159 } else if (ptype == V_ASN1_OBJECT) { 160 } else if (ptype == V_ASN1_OBJECT) {
160 const ASN1_OBJECT *poid = pval; 161 const ASN1_OBJECT *poid = pval;
161 EC_GROUP *group;
162 162
163 /* 163 /*
164 * type == V_ASN1_OBJECT => the parameters are given by an 164 * type == V_ASN1_OBJECT => the parameters are given by an
@@ -174,17 +174,17 @@ eckey_type2param(int ptype, const void *pval)
174 EC_GROUP_set_asn1_flag(group, OPENSSL_EC_NAMED_CURVE); 174 EC_GROUP_set_asn1_flag(group, OPENSSL_EC_NAMED_CURVE);
175 if (EC_KEY_set_group(eckey, group) == 0) 175 if (EC_KEY_set_group(eckey, group) == 0)
176 goto ecerr; 176 goto ecerr;
177 EC_GROUP_free(group);
178 } else { 177 } else {
179 ECerror(EC_R_DECODE_ERROR); 178 ECerror(EC_R_DECODE_ERROR);
180 goto ecerr; 179 goto ecerr;
181 } 180 }
182 181
182 EC_GROUP_free(group);
183 return eckey; 183 return eckey;
184 184
185 ecerr: 185 ecerr:
186 if (eckey) 186 EC_KEY_free(eckey);
187 EC_KEY_free(eckey); 187 EC_GROUP_free(group);
188 return NULL; 188 return NULL;
189} 189}
190 190