]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Clean up some redundant stuff in crypto_dh_new().
authorNick Mathewson <nickm@torproject.org>
Fri, 5 Sep 2008 20:18:22 +0000 (20:18 +0000)
committerNick Mathewson <nickm@torproject.org>
Fri, 5 Sep 2008 20:18:22 +0000 (20:18 +0000)
svn:r16778

src/common/crypto.c

index b158967a35b9a32b1067569ad78005b05bda0b8c..e1b401213881f9b5ca095175c19375e3b6eafc89 100644 (file)
@@ -1465,13 +1465,11 @@ init_dh_param(void)
 crypto_dh_env_t *
 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)
     init_dh_param();
 
-  res = tor_malloc_zero(sizeof(crypto_dh_env_t));
-
   if (!(res->dh = DH_new()))
     goto err;
 
@@ -1486,8 +1484,8 @@ crypto_dh_new(void)
   return res;
  err:
   crypto_log_errors(LOG_WARN, "creating DH object");
-  if (res && res->dh) DH_free(res->dh); /* frees p and g too */
-  if (res) tor_free(res);
+  if (res->dh) DH_free(res->dh); /* frees p and g too */
+  tor_free(res);
   return NULL;
 }