mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
gresolver: Ensure GThreadedResolver always sets an error if resolution fails
It was previously possible for GThreadedResolver to return an empty list and no error in response to a g_resolver_lookup_by_name() call, if it happened that all the addresses returned by getaddrinfo() could not be converted from native addresses to GSocketAddresses. Fix that by setting a G_RESOLVER_ERROR_NOT_FOUND if the returned list is empty. https://bugzilla.gnome.org/show_bug.cgi?id=728776
This commit is contained in:
parent
14b0c15abb
commit
956921e51f
@ -96,9 +96,22 @@ do_lookup_by_name (GTask *task,
|
||||
g_object_unref (sockaddr);
|
||||
}
|
||||
|
||||
addresses = g_list_reverse (addresses);
|
||||
g_task_return_pointer (task, addresses,
|
||||
(GDestroyNotify)g_resolver_free_addresses);
|
||||
if (addresses != NULL)
|
||||
{
|
||||
addresses = g_list_reverse (addresses);
|
||||
g_task_return_pointer (task, addresses,
|
||||
(GDestroyNotify)g_resolver_free_addresses);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* All addresses failed to be converted to GSocketAddresses. */
|
||||
g_task_return_new_error (task,
|
||||
G_RESOLVER_ERROR,
|
||||
G_RESOLVER_ERROR_NOT_FOUND,
|
||||
_("Error resolving '%s': %s"),
|
||||
hostname,
|
||||
_("No valid addresses were found"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user