]> git.sesse.net Git - cubemap/commitdiff
Fix some memory leaks that are probably irrelevant in practice.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 2 Apr 2023 20:10:31 +0000 (22:10 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 2 Apr 2023 20:10:31 +0000 (22:10 +0200)
httpinput.cpp
server.cpp

index 62ed663611402cef5d4517cef00d8033300391bc..a972fa2ca9eb7d4b8783bc72fb5b2cda647bcd85 100644 (file)
@@ -167,6 +167,7 @@ int HTTPInput::lookup_and_connect(const string &host, const string &port)
                        log(WARNING, "[%s] Lookup of '%s' failed (%s).",
                                url.c_str(), host.c_str(), gai_strerror(err));
                }
+               freeaddrinfo(ai);
                return -1;
        }
 
@@ -198,6 +199,7 @@ int HTTPInput::lookup_and_connect(const string &host, const string &port)
                        bool complete = wait_for_activity(sock, POLLIN | POLLOUT, nullptr);
                        if (should_stop()) {
                                safe_close(sock);
+                               freeaddrinfo(base_ai);
                                return -1;
                        }
                        if (complete) {
index a6f45744e1576b03065c712767bf4cea5078eb45..8025fd1b4cb257ee71aa6a280a98c1913e007e73 100644 (file)
@@ -70,6 +70,11 @@ Server::Server()
 Server::~Server()
 {
        safe_close(epoll_fd);
+
+       // We're going to die soon anyway, but clean this up to keep leak checking happy.
+       for (const auto &acceptor_and_context : tls_server_contexts) {
+               tls_destroy_context(acceptor_and_context.second);
+       }
 }
 
 vector<ClientStats> Server::get_client_stats() const