From b0b5cad4968b09b805b475b41c0a9005f79c9563 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Thu, 1 Aug 2013 23:38:35 +0100 Subject: [PATCH] Grouped sessions were being leaked on destroy, correctly free them. --- server-fn.c | 7 ++++--- session.c | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/server-fn.c b/server-fn.c index 86e2054e..738a61da 100644 --- a/server-fn.c +++ b/server-fn.c @@ -398,14 +398,15 @@ void server_destroy_session_group(struct session *s) { struct session_group *sg; + struct session *s1; if ((sg = session_group_find(s)) == NULL) server_destroy_session(s); else { - TAILQ_FOREACH(s, &sg->sessions, gentry) + TAILQ_FOREACH_SAFE(s, &sg->sessions, gentry, s1) { server_destroy_session(s); - TAILQ_REMOVE(&session_groups, sg, entry); - free(sg); + session_destroy(s); + } } } diff --git a/session.c b/session.c index 74eb06a5..24e2e5e7 100644 --- a/session.c +++ b/session.c @@ -150,6 +150,7 @@ void session_destroy(struct session *s) { struct winlink *wl; + log_debug("session %s destroyed", s->name); RB_REMOVE(sessions, &sessions, s);