err = inet_aton(MULTICAST_IPV4_ADDR, &imreq.imr_multiaddr.s_addr);
if (err != 1) {
ESP_LOGE(V4TAG, "Configured IPV4 multicast address '%s' is invalid.", MULTICAST_IPV4_ADDR);
+ // Errors in the return value have to be negative
+ err = -1;
goto err;
}
ESP_LOGI(TAG, "Configured IPV4 Multicast address %s", inet_ntoa(imreq.imr_multiaddr.s_addr));
ESP_LOGE(TAG, "getaddrinfo() failed for IPV4 destination address. error: %d", err);
break;
}
+ if (res == 0) {
+ ESP_LOGE(TAG, "getaddrinfo() did not return any addresses");
+ break;
+ }
#ifdef CONFIG_EXAMPLE_IPV4_ONLY
((struct sockaddr_in *)res->ai_addr)->sin_port = htons(UDP_PORT);
inet_ntoa_r(((struct sockaddr_in *)res->ai_addr)->sin_addr, addrbuf, sizeof(addrbuf)-1);