diff --git a/modules/ssl/ssl_engine_init.c b/modules/ssl/ssl_engine_init.c
index ee46db4..c560422 100644
--- a/modules/ssl/ssl_engine_init.c
+++ b/modules/ssl/ssl_engine_init.c
@@ -915,7 +915,7 @@ static void ssl_init_server_certs(server_rec *s,
     const char *rsa_id, *dsa_id;
 #ifndef OPENSSL_NO_EC
     const char *ecc_id;
-    EC_GROUP *ecparams;
+    EC_GROUP *ecparams = NULL;
     int nid;
     EC_KEY *eckey = NULL;
 #endif
@@ -988,6 +988,7 @@ static void ssl_init_server_certs(server_rec *s,
                      "Custom DH parameters (%d bits) for %s loaded from %s",
                      BN_num_bits(dhparams->p), vhost_id,
                      mctx->pks->cert_files[0]);
+        DH_free(dhparams);
     }
 
 #ifndef OPENSSL_NO_EC
@@ -1012,6 +1013,9 @@ static void ssl_init_server_certs(server_rec *s,
         SSL_CTX_set_tmp_ecdh(mctx->ssl_ctx, eckey);
 #endif
     }
+    if (ecparams) {
+        EC_GROUP_free(ecparams);
+    }
     EC_KEY_free(eckey);
 #endif
 }
