Dont leak addrinfo in error path
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Fri, 16 Nov 2012 02:38:54 +0000 (13:38 +1100)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Sat, 24 Nov 2012 16:14:12 +0000 (08:14 -0800)
lib/socket.c

index 3fa8378d9102b0127ded464dd9439d47258a7a53..32c09457c09b9189bf9c4bf65542dc4f860cd886 100644 (file)
@@ -598,6 +598,7 @@ int rpc_set_udp_destination(struct rpc_context *rpc, char *addr, int port, int i
        rpc->udp_dest = malloc(ai->ai_addrlen);
        if (rpc->udp_dest == NULL) {
                rpc_set_error(rpc, "Out of memory. Failed to allocate sockaddr structure");
+               freeaddrinfo(ai);
                return -1;
        }
        memcpy(rpc->udp_dest, ai->ai_addr, ai->ai_addrlen);