mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
udp_multicast example: Fix memory leak from getaddrinfo() calls
Closes https://github.com/espressif/esp-idf/issues/2201
This commit is contained in:
parent
a7d00f44ab
commit
5fb665dbaf
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user