1
0
mirror of https://frontier.innolan.net/rainlance/c-ares.git synced 2025-10-06 02:59:37 +00:00

ares_dup: clear new channel on failure

If the attempt to transfer IPv6 servers from the old to the new channel
fails, the previous code would still return a channel to the user even though
an error return code was generated.  This makes it likely that users would
leak the channel, so explicitly clear the channel in this case.
This commit is contained in:
David Drysdale
2015-12-23 12:28:16 +00:00
parent 46bb820be3
commit 970dea47b7

View File

@ -307,12 +307,18 @@ int ares_dup(ares_channel *dest, ares_channel src)
}
if (ipv6_nservers) {
rc = ares_get_servers(src, &servers);
if (rc != ARES_SUCCESS)
if (rc != ARES_SUCCESS) {
ares_destroy(*dest);
*dest = NULL;
return rc;
}
rc = ares_set_servers(*dest, servers);
ares_free_data(servers);
if (rc != ARES_SUCCESS)
if (rc != ARES_SUCCESS) {
ares_destroy(*dest);
*dest = NULL;
return rc;
}
}
return ARES_SUCCESS; /* everything went fine */