diff options
author | Maciej S. Szmigiero <mail@maciej.szmigiero.name> | 2022-10-09 23:34:06 +0200 |
---|---|---|
committer | Maciej S. Szmigiero <mail@maciej.szmigiero.name> | 2022-10-11 14:51:41 +0200 |
commit | 93351f169bc57bc993d7dbaacce601ec25b1c60f (patch) | |
tree | 4316a134b4200a353c49c9cd774d804371b2b6ce /src/gclue-modem-gps.c | |
parent | 3689c50e15b7e67017f961f66605d2de68c08a64 (diff) |
Make sure to not cast user_data to GObjects in callback if call is canceled
This can abort at runtime if the object pointed to by user_data is already
gone by the time the callback is run.
Diffstat (limited to 'src/gclue-modem-gps.c')
-rw-r--r-- | src/gclue-modem-gps.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/gclue-modem-gps.c b/src/gclue-modem-gps.c index c258eda..fba6bcb 100644 --- a/src/gclue-modem-gps.c +++ b/src/gclue-modem-gps.c @@ -80,14 +80,15 @@ on_gps_enabled (GObject *source_object, GAsyncResult *result, gpointer user_data) { - GClueModemGPS *source = GCLUE_MODEM_GPS (user_data); - GError *error = NULL; + g_autoptr(GError) error = NULL; - if (!gclue_modem_enable_gps_finish (source->priv->modem, + if (!gclue_modem_enable_gps_finish (GCLUE_MODEM (source_object), result, &error)) { - g_warning ("Failed to enable GPS: %s", error->message); - g_error_free (error); + if (error && !g_error_matches (error, G_IO_ERROR, + G_IO_ERROR_CANCELLED)) { + g_warning ("Failed to enable GPS: %s", error->message); + } } } |