diff --git a/sesman/libscp/libscp_v1s.c b/sesman/libscp/libscp_v1s.c index 284c9b52..a03fea38 100644 --- a/sesman/libscp/libscp_v1s.c +++ b/sesman/libscp/libscp_v1s.c @@ -330,7 +330,6 @@ scp_v1s_request_password(struct SCP_CONNECTION *c, struct SCP_SESSION *s, if (0 != scp_session_set_username(s, buf)) { - scp_session_destroy(s); log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: internal error", __LINE__); return SCP_SERVER_STATE_INTERNAL_ERR; } @@ -342,7 +341,6 @@ scp_v1s_request_password(struct SCP_CONNECTION *c, struct SCP_SESSION *s, if (0 != scp_session_set_password(s, buf)) { - scp_session_destroy(s); log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: internal error", __LINE__); return SCP_SERVER_STATE_INTERNAL_ERR; } 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; } diff --git a/sesman/scp_v1.c b/sesman/scp_v1.c index 1501606d..df138147 100644 --- a/sesman/scp_v1.c +++ b/sesman/scp_v1.c @@ -77,7 +77,6 @@ scp_v1_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s) default: /* we check the other errors */ parseCommonStates(e, "scp_v1s_list_sessions()"); - scp_session_destroy(s); return; //break; } @@ -88,7 +87,6 @@ scp_v1_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s) scp_v1s_deny_connection(c, "Login failed"); log_message( LOG_LEVEL_INFO, "Login failed for user %s. Connection terminated", s->username); - scp_session_destroy(s); return; } @@ -98,7 +96,6 @@ scp_v1_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s) scp_v1s_deny_connection(c, "Access to Terminal Server not allowed."); log_message(LOG_LEVEL_INFO, "User %s not allowed on TS. Connection terminated", s->username); - scp_session_destroy(s); return; } @@ -204,7 +201,6 @@ scp_v1_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s) } /* cleanup */ - scp_session_destroy(s); auth_end(data); g_free(slist); } diff --git a/sesman/scp_v1_mng.c b/sesman/scp_v1_mng.c index 29496466..61789cce 100644 --- a/sesman/scp_v1_mng.c +++ b/sesman/scp_v1_mng.c @@ -50,7 +50,6 @@ scp_v1_mng_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s) scp_v1s_mng_deny_connection(c, "Login failed"); log_message(LOG_LEVEL_INFO, "[MNG] Login failed for user %s. Connection terminated", s->username); - scp_session_destroy(s); auth_end(data); return; } @@ -61,7 +60,6 @@ scp_v1_mng_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s) scp_v1s_mng_deny_connection(c, "Access to Terminal Server not allowed."); log_message(LOG_LEVEL_INFO, "[MNG] User %s not allowed on TS. Connection terminated", s->username); - scp_session_destroy(s); auth_end(data); return; } @@ -105,7 +103,6 @@ scp_v1_mng_process(struct SCP_CONNECTION *c, struct SCP_SESSION *s) } /* cleanup */ - scp_session_destroy(s); auth_end(data); }