diff --git a/examples/protocols/udp_multicast/main/udp_multicast_example_main.c b/examples/protocols/udp_multicast/main/udp_multicast_example_main.c index 18678d0ea..a8efd1f08 100644 --- a/examples/protocols/udp_multicast/main/udp_multicast_example_main.c +++ b/examples/protocols/udp_multicast/main/udp_multicast_example_main.c @@ -506,6 +506,7 @@ static void mcast_example_task(void *pvParameters) ESP_LOGI(TAG, "Sending to IPV6 (V4 mapped) multicast address %s (%s)...", addrbuf, CONFIG_EXAMPLE_MULTICAST_IPV4_ADDR); #endif err = sendto(sock, sendbuf, len, 0, res->ai_addr, res->ai_addrlen); + freeaddrinfo(res); if (err < 0) { ESP_LOGE(TAG, "IPV4 sendto failed. errno: %d", errno); break; @@ -523,12 +524,12 @@ static void mcast_example_task(void *pvParameters) break; } - struct sockaddr_in6 *s6addr = (struct sockaddr_in6 *)res->ai_addr; s6addr->sin6_port = htons(UDP_PORT); inet6_ntoa_r(s6addr->sin6_addr, addrbuf, sizeof(addrbuf)-1); ESP_LOGI(TAG, "Sending to IPV6 multicast address %s...", addrbuf); err = sendto(sock, sendbuf, len, 0, res->ai_addr, res->ai_addrlen); + freeaddrinfo(res); if (err < 0) { ESP_LOGE(TAG, "IPV6 sendto failed. errno: %d", errno); break;