Skip to content

Commit 6fcae63

Browse files
committed
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.
1 parent b53bb3c commit 6fcae63

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

ext/ftp/ftp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,10 @@ ftp_login(ftpbuf_t *ftp, const char *user, const size_t user_len, const char *pa
287287
SSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_BOTH);
288288

289289
ftp->ssl_handle = SSL_new(ctx);
290+
SSL_CTX_free(ctx);
291+
290292
if (ftp->ssl_handle == NULL) {
291293
php_error_docref(NULL, E_WARNING, "failed to create the SSL handle");
292-
SSL_CTX_free(ctx);
293294
return 0;
294295
}
295296

0 commit comments

Comments
 (0)