Move freeaddrinfo() to inside of our loop; this prevents a memory leak
authorKen Hornstein <kenh@pobox.com>
Fri, 16 Jan 2009 15:48:09 +0000 (15:48 +0000)
committerKen Hornstein <kenh@pobox.com>
Fri, 16 Jan 2009 15:48:09 +0000 (15:48 +0000)
and also prevents it from being called with a NULL pointer.

sbr/client.c

index ae6968f..732fb47 100644 (file)
@@ -111,9 +111,10 @@ client (char *args, char *service, char *response, int len_response, int debug)
 
            close(sd);
        }
+
+       freeaddrinfo(res);
     }
 
-    freeaddrinfo(res);
     client_freelist(ap);
     strncpy (response, "no servers available", len_response);
     return NOTOK;