mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-25 05:26:14 +01:00
Merge branch 'wip/tingping/socketclient-cancel-2' into 'master'
gsocketclient: Fix potential critical when cancelling connect Closes #1747 See merge request GNOME/glib!783
This commit is contained in:
commit
b17436d952
@ -1427,15 +1427,24 @@ g_socket_client_async_connect_complete (GSocketClientAsyncConnectData *data)
|
||||
data->connection = (GIOStream *)wrapper_connection;
|
||||
}
|
||||
|
||||
if (!g_task_return_error_if_cancelled (data->task))
|
||||
if (!data->completed)
|
||||
{
|
||||
g_socket_client_emit_event (data->client, G_SOCKET_CLIENT_COMPLETE, data->connectable, data->connection);
|
||||
g_task_return_pointer (data->task, g_steal_pointer (&data->connection), g_object_unref);
|
||||
}
|
||||
else
|
||||
g_socket_client_emit_event (data->client, G_SOCKET_CLIENT_COMPLETE, data->connectable, NULL);
|
||||
GError *error = NULL;
|
||||
|
||||
if (g_cancellable_set_error_if_cancelled (g_task_get_cancellable (data->task), &error))
|
||||
{
|
||||
g_socket_client_emit_event (data->client, G_SOCKET_CLIENT_COMPLETE, data->connectable, NULL);
|
||||
g_task_return_error (data->task, g_steal_pointer (&error));
|
||||
}
|
||||
else
|
||||
{
|
||||
g_socket_client_emit_event (data->client, G_SOCKET_CLIENT_COMPLETE, data->connectable, data->connection);
|
||||
g_task_return_pointer (data->task, g_steal_pointer (&data->connection), g_object_unref);
|
||||
}
|
||||
|
||||
data->completed = TRUE;
|
||||
}
|
||||
|
||||
data->completed = TRUE;
|
||||
g_object_unref (data->task);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user