]> git.meshlink.io Git - meshlink/commitdiff
Don't free struct addrinfo too early. Spotted by Christian Cier-Zniewski.
authorGuus Sliepen <guus@tinc-vpn.org>
Wed, 16 May 2007 14:46:25 +0000 (14:46 +0000)
committerGuus Sliepen <guus@tinc-vpn.org>
Wed, 16 May 2007 14:46:25 +0000 (14:46 +0000)
src/mingw/device.c

index 6d916ba573c27841a01bf6ab7f7d99b0b56fd6bd..2813a8839cac9a9e45f01282cc4b1629596add27 100644 (file)
@@ -76,18 +76,20 @@ DWORD WINAPI tapreader(void *bla) {
 
        sock = socket(ai->ai_family, SOCK_STREAM, IPPROTO_TCP);
 
-       freeaddrinfo(ai);
-
        if(sock < 0) {
                logger(LOG_ERR, _("System call `%s' failed: %s"), "socket", strerror(errno));
+               freeaddrinfo(ai);
                return -1;
        }
 
        if(connect(sock, ai->ai_addr, ai->ai_addrlen)) {
                logger(LOG_ERR, _("System call `%s' failed: %s"), "connect", strerror(errno));
+               freeaddrinfo(ai);
                return -1;
        }
 
+       freeaddrinfo(ai);
+
        logger(LOG_DEBUG, _("Tap reader running"));
 
        /* Read from tap device and send to parent */