From: Nicola Tuveri Date: Wed, 5 Sep 2018 09:08:12 +0000 (+0300) Subject: Harmonize the error handling codepath X-Git-Tag: OpenSSL_1_1_1~42 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=544648a8e07612449460ebc0e608a226fde38e67;p=oweals%2Fopenssl.git Harmonize the error handling codepath Reviewed-by: Richard Levitte Reviewed-by: Tim Hudson Reviewed-by: Matt Caswell Reviewed-by: Matthias St. Pierre Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/7121) --- diff --git a/crypto/dh/dh_lib.c b/crypto/dh/dh_lib.c index 2e0393e475..962f864dee 100644 --- a/crypto/dh/dh_lib.c +++ b/crypto/dh/dh_lib.c @@ -83,12 +83,14 @@ DH *DH_new_method(ENGINE *engine) if ((ret->meth->init != NULL) && !ret->meth->init(ret)) { DHerr(DH_F_DH_NEW_METHOD, ERR_R_INIT_FAIL); -err: - DH_free(ret); - ret = NULL; + goto err; } return ret; + + err: + DH_free(ret); + return NULL; } void DH_free(DH *r) diff --git a/crypto/dsa/dsa_lib.c b/crypto/dsa/dsa_lib.c index 2eb8ee7ad5..1048601beb 100644 --- a/crypto/dsa/dsa_lib.c +++ b/crypto/dsa/dsa_lib.c @@ -90,12 +90,14 @@ DSA *DSA_new_method(ENGINE *engine) if ((ret->meth->init != NULL) && !ret->meth->init(ret)) { DSAerr(DSA_F_DSA_NEW_METHOD, ERR_R_INIT_FAIL); -err: - DSA_free(ret); - ret = NULL; + goto err; } return ret; + + err: + DSA_free(ret); + return NULL; } void DSA_free(DSA *r) diff --git a/crypto/ec/ec_kmeth.c b/crypto/ec/ec_kmeth.c index 5e5d1ae1cf..decad65a18 100644 --- a/crypto/ec/ec_kmeth.c +++ b/crypto/ec/ec_kmeth.c @@ -119,7 +119,7 @@ EC_KEY *EC_KEY_new_method(ENGINE *engine) } return ret; -err: + err: EC_KEY_free(ret); return NULL; } diff --git a/crypto/rsa/rsa_lib.c b/crypto/rsa/rsa_lib.c index 16e97c2a00..72d1b5e071 100644 --- a/crypto/rsa/rsa_lib.c +++ b/crypto/rsa/rsa_lib.c @@ -97,7 +97,7 @@ RSA *RSA_new_method(ENGINE *engine) return ret; -err: + err: RSA_free(ret); return NULL; }