Skip to content

Commit 575dab8

Browse files
committed
Fix memory leak in OpenSSLConnection
I checked, but as far back as the docs for 1.1, the docs say you should call free.
1 parent e520e59 commit 575dab8

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

src/generic/OpenSSLConnection.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ OpenSSLConnection::SSLFuncs::SSLFuncs()
6363
LoadSymbol(SSLv23_method, sslhandle, "TLS_method"));
6464

6565
valid = valid && LoadSymbol(check_host, cryptohandle, "X509_check_host");
66+
valid = valid && LoadSymbol(X509_free, cryptohandle, "X509_free");
6667

6768
if (library_init)
6869
library_init();
@@ -125,6 +126,7 @@ bool OpenSSLConnection::connect(const std::string &hostname, uint16_t port)
125126
close();
126127
return false;
127128
}
129+
ssl.X509_free(cert);
128130

129131
return true;
130132
}

src/generic/OpenSSLConnection.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class OpenSSLConnection : public Connection
5353
const SSL_METHOD *(*SSLv23_method)();
5454

5555
int (*check_host)(X509 *cert, const char *name, size_t namelen, unsigned int flags, char **peername);
56+
void (*X509_free)(X509* cert);
5657
};
5758
static SSLFuncs ssl;
5859
};

0 commit comments

Comments
 (0)