From 65ac8e758b6bd1458c8228613db4fec99d54d86f Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Sun, 16 Oct 2016 23:40:47 -0700 Subject: Fix memory leak: free session data Call scp_session_destroy() in the functions that call scp_session_create() and nowhere else. As found by Valgrind, the session data is not freed if the session is created successfully. --- sesman/scp.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'sesman/scp.c') diff --git a/sesman/scp.c b/sesman/scp.c index e4abe004..d81de0ab 100644 --- a/sesman/scp.c +++ b/sesman/scp.c @@ -36,7 +36,7 @@ void *DEFAULT_CC scp_process_start(void *sck) { struct SCP_CONNECTION scon; - struct SCP_SESSION *sdata; + struct SCP_SESSION *sdata = NULL; scon.in_sck = (int)(tintptr)sck; LOG_DBG("started scp thread on socket %d", scon.in_sck); @@ -89,9 +89,16 @@ scp_process_start(void *sck) break; default: log_message(LOG_LEVEL_ALWAYS, "unknown return from scp_vXs_accept()"); + break; } free_stream(scon.in_s); free_stream(scon.out_s); + + if (sdata) + { + scp_session_destroy(sdata); + } + return 0; } -- cgit v1.2.1