From 33ef4d63bc1eb7f60719417f11c90b42f9a1c100 Mon Sep 17 00:00:00 2001 From: Joe Orton Date: Thu, 19 Jun 2014 15:09:15 +0000 Subject: [PATCH] * modules/ssl/ssl_engine_init.c (make_dh_params): Remove redundant temporary variable; no functional change. (free_dh_params): Add comment. Submitted by: rpluem, jorton git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1603915 13f79535-47bb-0310-9956-ffa450edef68 --- modules/ssl/ssl_engine_init.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/modules/ssl/ssl_engine_init.c b/modules/ssl/ssl_engine_init.c index 592df604e2..3bd42b48c1 100644 --- a/modules/ssl/ssl_engine_init.c +++ b/modules/ssl/ssl_engine_init.c @@ -53,22 +53,17 @@ APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ssl, SSL, int, init_server, */ static DH *make_dh_params(BIGNUM *(*prime)(BIGNUM *), const char *gen) { - DH *dh = NULL; - DH *dh_tmp; + DH *dh = DH_new(); - if (dh) { - return dh; - } - if (!(dh_tmp = DH_new())) { + if (!dh) { return NULL; } - dh_tmp->p = prime(NULL); - BN_dec2bn(&dh_tmp->g, gen); - if (!dh_tmp->p || !dh_tmp->g) { - DH_free(dh_tmp); + dh->p = prime(NULL); + BN_dec2bn(&dh->g, gen); + if (!dh->p || !dh->g) { + DH_free(dh); return NULL; } - dh = dh_tmp; return dh; } @@ -87,6 +82,9 @@ static void init_dh_params(void) static void free_dh_params(void) { + /* DH_free() is a noop for a NULL parameter, so these are harmless + * in the (unexpected) case where these variables are already + * NULL. */ DH_free(dhparam1024); DH_free(dhparam2048); DH_free(dhparam3072); -- 2.40.0