Do not crash looking for next or previous session. GitHub issue 5344.

This commit is contained in:
nicm
2026-07-08 08:15:49 +00:00
committed by Nicholas Marriott
parent 8237d72900
commit c515d8cae0

View File

@@ -438,6 +438,7 @@ server_destroy_session(struct session *s)
{
struct client *c;
struct session *s_new = NULL, *cs_new = NULL, *use_s;
struct sort_criteria sort_crit = { .order = SORT_NAME };
int detach_on_destroy;
detach_on_destroy = options_get_number(s->options, "detach-on-destroy");
@@ -446,9 +447,11 @@ server_destroy_session(struct session *s)
else if (detach_on_destroy == 2)
s_new = server_find_session(s, server_newer_detached_session);
else if (detach_on_destroy == 3)
s_new = session_previous_session(s, NULL);
s_new = session_previous_session(s, &sort_crit);
else if (detach_on_destroy == 4)
s_new = session_next_session(s, NULL);
s_new = session_next_session(s, &sort_crit);
if (s_new == s)
s_new = NULL;
/*
* If no suitable new session was found above, then look for any