From: Martin Kraemer Date: Tue, 20 Sep 2005 14:42:31 +0000 (+0000) Subject: Fix Bug#: 25659 (Memory leak in ssl_util_algotypeof()) X-Git-Tag: 2.3.0~2983 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e81d81c374a4252876a09069ea4a5d6cdb5b674c;p=apache Fix Bug#: 25659 (Memory leak in ssl_util_algotypeof()) Reported by David Blake in 2003, including patch. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@290459 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/ssl/ssl_util.c b/modules/ssl/ssl_util.c index bd6c2c8e81..edfcb09643 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; }