From 05a6699939e83aeeb6b850e055401b6a98880d6e Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Wed, 7 Jun 2023 07:14:29 +0100 Subject: [PATCH] PSFTP: fix memory leak opening two consecutive sessions. Testing the script described in the previous commit message, Leak Sanitiser pointed out that we didn't free the LogContext from the first connection, and overwrote the pointer variable with the one from the second. --- psftp.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/psftp.c b/psftp.c index 08796837..587e2177 100644 --- a/psftp.c +++ b/psftp.c @@ -2386,6 +2386,10 @@ static void do_sftp_cleanup(void) sfree(homedir); homedir = NULL; } + if (psftp_logctx) { + log_free(psftp_logctx); + psftp_logctx = NULL; + } } int do_sftp(int mode, int modeflags, char *batchfile)