From f56e7627e5fbde3705f9241e6bcaeafe8c123674 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Tue, 22 Mar 2022 21:05:19 +0100 Subject: [PATCH] server: Fix memory leak at exit. If command_post_select() returns failure because of a notification we leak the array of listening fds. No big deal, but worth to fix anyway. --- server.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/server.c b/server.c index 09087f7a..d51e4e0b 100644 --- a/server.c +++ b/server.c @@ -432,15 +432,16 @@ static int command_post_select(struct sched *s, void *context) ret = task_get_notification(sct->task); if (ret < 0) - return ret; + goto fail; for (n = 0; n < sct->num_listen_fds; n++) { ret = command_task_accept(n, s, sct); - if (ret < 0) { - free(sct->listen_fds); - return ret; - } + if (ret < 0) + goto fail; } return 0; +fail: + free(sct->listen_fds); + return ret; } static void init_server_command_task(struct server_command_task *sct, -- 2.39.5