Harmonize the error handling codepath
authorNicola Tuveri <nic.tuv@gmail.com>
Wed, 5 Sep 2018 09:08:12 +0000 (12:08 +0300)
committerNicola Tuveri <nic.tuv@gmail.com>
Wed, 5 Sep 2018 12:22:35 +0000 (15:22 +0300)
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)

crypto/dh/dh_lib.c
crypto/dsa/dsa_lib.c
crypto/ec/ec_kmeth.c
crypto/rsa/rsa_lib.c

index 2e0393e475fb918382a3ab2579ef392e99d116e9..962f864deec6141535ab924fe5df5b4222ae9b4b 100644 (file)
@@ -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)
index 2eb8ee7ad5a2394e6f18bde42972fc230f55f4ef..1048601bebde3896bddf4a06a6c3a6358ce4b0da 100644 (file)
@@ -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)
index 5e5d1ae1cf41f7b8a4e9a538a1c0307ea9f4933a..decad65a18a632f320d9c713678bd2df92bf4162 100644 (file)
@@ -119,7 +119,7 @@ EC_KEY *EC_KEY_new_method(ENGINE *engine)
     }
     return ret;
 
-err:
+ err:
     EC_KEY_free(ret);
     return NULL;
 }
index 16e97c2a003daf4e6fdc36c9659bd45222d18913..72d1b5e0715d678ddd78731ad4041161c3cbd71b 100644 (file)
@@ -97,7 +97,7 @@ RSA *RSA_new_method(ENGINE *engine)
 
     return ret;
 
-err:
+ err:
     RSA_free(ret);
     return NULL;
 }