[mdns] Fix incorrect error check for getaddrinfo (can cause segfault)

Non-zero return from getaddrinfo is an error, so since *ai could be a null
pointer when derefenced in the following socket() call.
This commit is contained in:
ejurgensen 2019-09-18 21:18:01 +02:00
parent 4ab734343c
commit 6836a0f277

View File

@ -498,7 +498,7 @@ connection_test(int family, const char *address, const char *address_log, int po
snprintf(strport, sizeof(strport), "%d", port);
ret = getaddrinfo(address, strport, &hints, &ai);
if (ret < 0)
if (ret != 0)
{
DPRINTF(E_WARN, L_MDNS, "Connection test to %s:%d failed with getaddrinfo error: %s\n", address_log, port, gai_strerror(ret));
return -1;