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, 17 Nov 2012 18:14:19 +0000 (10:14 -0800)
lib/socket.c

index 1bb34f0ef9e57212d7919d4fee3d0d524c3488f6..8ad5e4e891b3814bd899c500dc9d5546e7e7d570 100644 (file)
@@ -599,6 +599,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);