From 9abaf929b9da3158e9b7f799775ac56e88d28740 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Tue, 16 Apr 2013 22:33:11 +0200 Subject: [PATCH] Fix a small memory leak in HTTPInput. --- httpinput.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/httpinput.cpp b/httpinput.cpp index f6a9979..72a8f3a 100644 --- a/httpinput.cpp +++ b/httpinput.cpp @@ -93,6 +93,8 @@ int HTTPInput::lookup_and_connect(const string &host, const string &port) return -1; } + addrinfo *base_ai = ai; + // Connect to everything in turn until we have a socket. while (ai && !should_stop) { int sock = socket(ai->ai_family, SOCK_STREAM, IPPROTO_TCP); @@ -106,7 +108,7 @@ int HTTPInput::lookup_and_connect(const string &host, const string &port) } while (err == -1 && errno == EINTR); if (err != -1) { - freeaddrinfo(ai); + freeaddrinfo(base_ai); return sock; } @@ -125,7 +127,7 @@ int HTTPInput::lookup_and_connect(const string &host, const string &port) // Give the last one as error. log(WARNING, "[%s] Connect to '%s' failed (%s)", stream_id.c_str(), host.c_str(), strerror(errno)); - freeaddrinfo(ai); + freeaddrinfo(base_ai); return -1; } -- 2.39.2