]> git.sesse.net Git - cubemap/commitdiff
Fix a possible infinite loop in HTTPInput.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 15 May 2013 20:26:31 +0000 (22:26 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 15 May 2013 20:26:31 +0000 (22:26 +0200)
httpinput.cpp

index cc618bc7849b11464b29afac557af6228c5c497c..301aa3f9f81ebfe5c6b5d2f519841e19ceb1bf50 100644 (file)
@@ -95,7 +95,7 @@ int HTTPInput::lookup_and_connect(const string &host, const string &port)
        addrinfo *base_ai = ai;
 
        // Connect to everything in turn until we have a socket.
-       while (ai && !should_stop()) {
+       for ( ; ai && !should_stop(); ai = ai->ai_next) {
                int sock = socket(ai->ai_family, SOCK_STREAM, IPPROTO_TCP);
                if (sock == -1) {
                        // Could be e.g. EPROTONOSUPPORT. The show must go on.
@@ -153,7 +153,6 @@ int HTTPInput::lookup_and_connect(const string &host, const string &port)
                }
 
                safe_close(sock);
-               ai = ai->ai_next;
        }
 
        // Give the last one as error.