mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-14 00:06:24 +01:00
gsocketclient: Fix potential critical when cancelling connect
We are manually tracking the completion state of the connect task so avoid just calling g_task_return_error_if_cancelled() without checking that. Fixes #1747
This commit is contained in:
parent
c95e2ae9c9
commit
313e7cbad7
@ -1427,15 +1427,24 @@ g_socket_client_async_connect_complete (GSocketClientAsyncConnectData *data)
|
|||||||
data->connection = (GIOStream *)wrapper_connection;
|
data->connection = (GIOStream *)wrapper_connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!g_task_return_error_if_cancelled (data->task))
|
if (!data->completed)
|
||||||
|
{
|
||||||
|
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_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);
|
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);
|
|
||||||
|
|
||||||
data->completed = TRUE;
|
data->completed = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
g_object_unref (data->task);
|
g_object_unref (data->task);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user