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_0j~46 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=a842be9cf7bdf3cb3abbfe152d811cbc57dded27;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 d277faa398..4bc62a63c0 100644 --- a/crypto/dh/dh_lib.c +++ b/crypto/dh/dh_lib.c @@ -82,12 +82,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 92758ca4c6..9600c614f6 100644 --- a/crypto/dsa/dsa_lib.c +++ b/crypto/dsa/dsa_lib.c @@ -91,12 +91,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 97552fa335..40dee36836 100644 --- a/crypto/rsa/rsa_lib.c +++ b/crypto/rsa/rsa_lib.c @@ -94,7 +94,7 @@ RSA *RSA_new_method(ENGINE *engine) return ret; -err: + err: RSA_free(ret); return NULL; }