From: Steinar H. Gunderson Date: Sun, 2 Apr 2023 20:10:31 +0000 (+0200) Subject: Fix some memory leaks that are probably irrelevant in practice. X-Git-Tag: 1.5.0~14 X-Git-Url: https://git.sesse.net/?p=cubemap;a=commitdiff_plain;h=5c2e4453f2f807a8ef3094902a1fc5544486c89a Fix some memory leaks that are probably irrelevant in practice. --- 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