Clean up some redundant stuff in crypto_dh_new().

svn:r16778
This commit is contained in:
Nick Mathewson 2008-09-05 20:18:22 +00:00
parent a56a072f29
commit 4d94e061c7

View File

@ -1465,13 +1465,11 @@ init_dh_param(void)
crypto_dh_env_t * crypto_dh_env_t *
crypto_dh_new(void) crypto_dh_new(void)
{ {
crypto_dh_env_t *res = NULL; crypto_dh_env_t *res = tor_malloc_zero(sizeof(crypto_dh_env_t));
if (!dh_param_p) if (!dh_param_p)
init_dh_param(); init_dh_param();
res = tor_malloc_zero(sizeof(crypto_dh_env_t));
if (!(res->dh = DH_new())) if (!(res->dh = DH_new()))
goto err; goto err;
@ -1486,8 +1484,8 @@ crypto_dh_new(void)
return res; return res;
err: err:
crypto_log_errors(LOG_WARN, "creating DH object"); crypto_log_errors(LOG_WARN, "creating DH object");
if (res && res->dh) DH_free(res->dh); /* frees p and g too */ if (res->dh) DH_free(res->dh); /* frees p and g too */
if (res) tor_free(res); tor_free(res);
return NULL; return NULL;
} }