From 96b717b7480314239736b19ae26db245385407b6 Mon Sep 17 00:00:00 2001 From: CismonX Date: Sun, 6 Sep 2026 06:17:29 +0800 Subject: server: fix use-after-free during shutdown When terminal shutdown is in progress, calling client_destroy() results in subsequent fdm_shutdown() (registered by term_shutdown()) always called with a dangling 'struct terminal' pointer. This may happen when footclient and the client application exit simultaneously in a short window. See #2432 for more information. Fixed by not calling client_destroy() when terminal shutdown is in progress. The client will eventually be destroyed in term_shutdown_handler() (invoked from shutdown_maybe_done()), so there's no resource leak. --- server.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'server.c') diff --git a/server.c b/server.c index 25963325..46560d5c 100644 --- a/server.c +++ b/server.c @@ -426,11 +426,9 @@ shutdown: fdm_del(fdm, fd); client->fd = -1; - if (client->instance != NULL && - !client->instance->terminal->shutdown.in_progress) - { + if (client->instance != NULL) term_shutdown(client->instance->terminal); - } else + else client_destroy(client); return true; -- cgit v1.3