]> git.sesse.net Git - cubemap/commitdiff
Fix a small memory leak in HTTPInput.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 16 Apr 2013 20:33:11 +0000 (22:33 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 16 Apr 2013 20:33:11 +0000 (22:33 +0200)
httpinput.cpp

index f6a99792afafea4da0bd7fe960808a376327b6e1..72a8f3aaf021e3c96afe345c6c7635b506ebb251 100644 (file)
@@ -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;
 }