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)
This commit is contained in:
Nicola Tuveri 2018-09-05 12:08:12 +03:00
parent 0c5d725ebf
commit 544648a8e0
4 changed files with 12 additions and 8 deletions

View 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)

View 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)

View file

@ -119,7 +119,7 @@ EC_KEY *EC_KEY_new_method(ENGINE *engine)
}
return ret;
err:
err:
EC_KEY_free(ret);
return NULL;
}

View file

@ -97,7 +97,7 @@ RSA *RSA_new_method(ENGINE *engine)
return ret;
err:
err:
RSA_free(ret);
return NULL;
}