[glib/wip/tingping/socketclient-cancel-2] gsocketclient: Fix potential critical when cancelling connect
- From: Patrick Griffis <pgriffis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/tingping/socketclient-cancel-2] gsocketclient: Fix potential critical when cancelling connect
- Date: Tue, 16 Apr 2019 17:27:34 +0000 (UTC)
commit 313e7cbad779fb36e3d999474e00a0a249d9f273
Author: Patrick Griffis <pgriffis igalia com>
Date: Tue Apr 16 10:22:35 2019 -0700
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
gio/gsocketclient.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
---
diff --git a/gio/gsocketclient.c b/gio/gsocketclient.c
index 83cb945c7..5faa02ecb 100644
--- a/gio/gsocketclient.c
+++ b/gio/gsocketclient.c
@@ -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);
+ 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;
}
- else
- g_socket_client_emit_event (data->client, G_SOCKET_CLIENT_COMPLETE, data->connectable, NULL);
- data->completed = TRUE;
g_object_unref (data->task);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]