diff options
author | Philip Withnall <philip@tecnocode.co.uk> | 2009-08-28 16:45:44 +0100 |
---|---|---|
committer | Philip Withnall <philip@tecnocode.co.uk> | 2009-08-28 16:48:11 +0100 |
commit | 9fffe702b9f39a850925e830d55cd2ca1bcfa3b9 (patch) | |
tree | c4c6c20af7a76e614c51fee1aaebcc94426cdff5 /gdata/gdata-service.c | |
parent | 38026d747eb9e26118885fc6ba83e3806c5cb21e (diff) | |
download | libgdata-9fffe702b9f39a850925e830d55cd2ca1bcfa3b9.tar.gz |
[core] Fix race condition when updating authentication details
If a GDataService is destroyed before the set_authentication_details_cb idle
callback is called, it will access freed memory. The authentication process
now keeps a reference to the service until it has finished updating the
service's authentication details.
Diffstat (limited to 'gdata/gdata-service.c')
-rw-r--r-- | gdata/gdata-service.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/gdata/gdata-service.c b/gdata/gdata-service.c index dd66abbb..d5cefa59 100644 --- a/gdata/gdata-service.c +++ b/gdata/gdata-service.c @@ -414,6 +414,8 @@ authenticate_async_data_free (AuthenticateAsyncData *self) { g_free (self->username); g_free (self->password); + if (self->service != NULL) + g_object_unref (self->service); g_slice_free (AuthenticateAsyncData, self); } @@ -470,7 +472,7 @@ authenticate_thread (GSimpleAsyncResult *result, GDataService *service, GCancell } /* Update the authentication details held by the service */ - data->service = service; + data->service = g_object_ref (service); g_idle_add ((GSourceFunc) set_authentication_details_cb, data); } @@ -505,6 +507,7 @@ gdata_service_authenticate_async (GDataService *self, const gchar *username, con data = g_slice_new (AuthenticateAsyncData); data->username = g_strdup (username); data->password = g_strdup (password); + data->service = NULL; /* set in authenticate_thread() */ result = g_simple_async_result_new (G_OBJECT (self), callback, user_data, gdata_service_authenticate_async); g_simple_async_result_set_op_res_gpointer (result, data, NULL); |