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 b5a60c0f9f
commit 2770b7eecd
Notes: sideshowbarker 2024-07-17 04:01:41 +09:00

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 {};