When looping through addrinfo lists matching addresses, keep a copy of the original addrinfo pointers to free instead of ending up at the terminating NULLs and trying to free those.
In the best case this fixes a mem leak. In implementations such as musl where freeaddrinfo(NULL) is not safe (which is not required by the spec), this fixes a segfault.
(I used the "rp" names to be consistent with other similar loops elsewhere in the code.)
When looping through addrinfo lists matching addresses, keep a copy of the original addrinfo pointers to free instead of ending up at the terminating NULLs and trying to free those.
In the best case this fixes a mem leak. In implementations such as musl where freeaddrinfo(NULL) is not safe (which is not required by the spec), this fixes a segfault.
(I used the "rp" names to be consistent with other similar loops elsewhere in the code.)