From: Martin Kraemer Date: Tue, 20 Sep 2005 15:02:23 +0000 (+0000) Subject: Merge r290459 from trunk: X-Git-Tag: 2.1.8~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5ecf83a4032457923ffd722ecaad36fd24e1078f;p=thirdparty%2Fapache%2Fhttpd.git Merge r290459 from trunk: Fix Bug#: 25659 (Memory leak in ssl_util_algotypeof()) Reported by David Blake in 2003, including patch. Reviewed by: martin git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@290463 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/ssl/ssl_util.c b/modules/ssl/ssl_util.c index bd6c2c8e81e..edfcb09643d 100644 --- a/modules/ssl/ssl_util.c +++ b/modules/ssl/ssl_util.c @@ -137,10 +137,11 @@ BOOL ssl_util_path_check(ssl_pathcheck_t pcm, const char *path, apr_pool_t *p) ssl_algo_t ssl_util_algotypeof(X509 *pCert, EVP_PKEY *pKey) { ssl_algo_t t; + EVP_PKEY *pFreeKey = NULL; t = SSL_ALGO_UNKNOWN; if (pCert != NULL) - pKey = X509_get_pubkey(pCert); + pFreeKey = pKey = X509_get_pubkey(pCert); if (pKey != NULL) { switch (EVP_PKEY_key_type(pKey)) { case EVP_PKEY_RSA: @@ -153,6 +154,11 @@ ssl_algo_t ssl_util_algotypeof(X509 *pCert, EVP_PKEY *pKey) break; } } +#ifdef OPENSSL_VERSION_NUMBER + /* Only refcounted in OpenSSL */ + if (pFreeKey != NULL) + EVP_PKEY_free(pFreeKey); +#endif return t; }