From 6fb2fd3dac7316f7155437d350ab372ed248b866 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Fri, 7 Jul 2023 15:44:52 +0200 Subject: server: fix a possible leak --- src/server.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/server.c b/src/server.c index 2fbb13c..da9cfc3 100644 --- a/src/server.c +++ b/src/server.c @@ -13,6 +13,7 @@ #include "file.h" #include "log.h" #include "msg.h" +#include "net.h" #include "process.h" #include "protocol.h" #include "run_queue.h" @@ -235,11 +236,12 @@ static int server_handle_cmd_new_worker(UNUSED const struct msg *request, if (ret < 0) return ret; + const int fd = ret; struct worker *worker = NULL; - ret = worker_create(&worker, ret); + ret = worker_create(&worker, fd); if (ret < 0) - return ret; + goto close; ret = server_enqueue_worker(server, worker); if (ret < 0) @@ -250,6 +252,9 @@ static int server_handle_cmd_new_worker(UNUSED const struct msg *request, destroy_worker: worker_destroy(worker); +close: + net_close(fd); + return ret; } -- cgit v1.2.3