From 6fcae63f614d1ed4aaeaff7b13a7a4627b1f1312 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 25 Jun 2019 12:09:47 +0200 Subject: [PATCH] Fix SSL_CTX leak in ftp extension SSL_CTX is a refcounted structure, which will be held by the SSL handle, so we can free it here. --- ext/ftp/ftp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ext/ftp/ftp.c b/ext/ftp/ftp.c index b1343976b6..e5355b1bd4 100644 --- a/ext/ftp/ftp.c +++ b/ext/ftp/ftp.c @@ -287,9 +287,10 @@ ftp_login(ftpbuf_t *ftp, const char *user, const size_t user_len, const char *pa SSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_BOTH); ftp->ssl_handle = SSL_new(ctx); + SSL_CTX_free(ctx); + if (ftp->ssl_handle == NULL) { php_error_docref(NULL, E_WARNING, "failed to create the SSL handle"); - SSL_CTX_free(ctx); return 0; } -- 2.50.1