diff options
author | Nicola Tuveri <nic.tuv@gmail.com> | 2018-09-05 12:08:12 +0300 |
---|---|---|
committer | Nicola Tuveri <nic.tuv@gmail.com> | 2018-09-05 15:26:46 +0300 |
commit | a842be9cf7bdf3cb3abbfe152d811cbc57dded27 (patch) | |
tree | e02d8e0bcae65d471fa383082805eeba038f7098 /crypto | |
parent | c28a2ffd01dc1da932aa55d518b57a933cdc51be (diff) |
Harmonize the error handling codepath
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/7121)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/dh/dh_lib.c | 8 | ||||
-rw-r--r-- | crypto/dsa/dsa_lib.c | 8 | ||||
-rw-r--r-- | crypto/ec/ec_kmeth.c | 2 | ||||
-rw-r--r-- | crypto/rsa/rsa_lib.c | 2 |
4 files changed, 12 insertions, 8 deletions
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; } |