From 5c2e4453f2f807a8ef3094902a1fc5544486c89a Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sun, 2 Apr 2023 22:10:31 +0200 Subject: [PATCH] Fix some memory leaks that are probably irrelevant in practice. --- httpinput.cpp | 2 ++ server.cpp | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/httpinput.cpp b/httpinput.cpp index 62ed663..a972fa2 100644 --- a/httpinput.cpp +++ b/httpinput.cpp @@ -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) { diff --git a/server.cpp b/server.cpp index a6f4574..8025fd1 100644 --- a/server.cpp +++ b/server.cpp @@ -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 Server::get_client_stats() const -- 2.39.2