From 45a3820560cdffbaa5abbfa5407c8f9bd88b44a8 Mon Sep 17 00:00:00 2001 From: lhywk Date: Wed, 25 Jun 2025 04:47:03 +0000 Subject: [PATCH] Fix: close server_fd on brain_server() --- src/brain.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/brain.c b/src/brain.c index fbb1f206a..88b896c55 100644 --- a/src/brain.c +++ b/src/brain.c @@ -3052,6 +3052,8 @@ int brain_server (const char *listen_host, const int listen_port, const char *br { brain_logging (stderr, 0, "setsockopt: %s\n", strerror (errno)); + close(server_fd); + if (brain_password == NULL) hcfree (auth_password); return -1; @@ -3061,6 +3063,8 @@ int brain_server (const char *listen_host, const int listen_port, const char *br { brain_logging (stderr, 0, "setsockopt: %s\n", strerror (errno)); + close(server_fd); + if (brain_password == NULL) hcfree (auth_password); return -1; @@ -3104,6 +3108,8 @@ int brain_server (const char *listen_host, const int listen_port, const char *br { brain_logging (stderr, 0, "%s: %s\n", listen_host, gai_strerror (rc_getaddrinfo)); + close(server_fd); + if (brain_password == NULL) hcfree (auth_password); return -1; @@ -3114,6 +3120,8 @@ int brain_server (const char *listen_host, const int listen_port, const char *br { brain_logging (stderr, 0, "bind: %s\n", strerror (errno)); + close(server_fd); + if (brain_password == NULL) hcfree (auth_password); return -1; @@ -3123,6 +3131,8 @@ int brain_server (const char *listen_host, const int listen_port, const char *br { brain_logging (stderr, 0, "listen: %s\n", strerror (errno)); + close(server_fd); + if (brain_password == NULL) hcfree (auth_password); return -1;