LibCore: Null-check struct addrinfo to avoid freeaddrinfo(NULL)

On some C libraries, like NetBSD and musl-libc, this under-specified
edge case results in a crash rather than silently ignoring the null
pointer.
This commit is contained in:
Andrew Kaster 2024-05-09 15:13:48 -06:00 committed by Andrew Kaster
parent 605aa2e34b
commit 3bb41e942f

View file

@ -264,7 +264,11 @@ private:
}
struct AddrInfoDeleter {
void operator()(struct addrinfo* ptr) { ::freeaddrinfo(ptr); }
void operator()(struct addrinfo* ptr)
{
if (ptr)
::freeaddrinfo(ptr);
}
};
Vector<struct addrinfo> m_addresses {};