Prechádzať zdrojové kódy

Fix memory leak in OpenSSLConnection

I checked, but as far back as the docs for 1.1, the docs say you should call free.
Bart van Strien 1 rok pred
rodič
commit
575dab8be5

+ 2 - 0
src/generic/OpenSSLConnection.cpp

@@ -63,6 +63,7 @@ OpenSSLConnection::SSLFuncs::SSLFuncs()
 			LoadSymbol(SSLv23_method, sslhandle, "TLS_method"));
 
 	valid = valid && LoadSymbol(check_host, cryptohandle, "X509_check_host");
+	valid = valid && LoadSymbol(X509_free, cryptohandle, "X509_free");
 
 	if (library_init)
 		library_init();
@@ -125,6 +126,7 @@ bool OpenSSLConnection::connect(const std::string &hostname, uint16_t port)
 		close();
 		return false;
 	}
+	ssl.X509_free(cert);
 
 	return true;
 }

+ 1 - 0
src/generic/OpenSSLConnection.h

@@ -53,6 +53,7 @@ private:
 		const SSL_METHOD *(*SSLv23_method)();
 
 		int (*check_host)(X509 *cert, const char *name, size_t namelen, unsigned int flags, char **peername);
+		void (*X509_free)(X509* cert);
 	};
 	static SSLFuncs ssl;
 };