internal-place-file: Don't access self pointer after destruction

If the file is destroyed before the mount operation is completed,
we cancel the mount operation.

However, due to the nature of GAsyncResult, the callback is still
called in a future iteration of the main loop, when the file is
long gone. But since it's passed as callback data, we try to
cast it, with predictably bad results.

Access the file pointer only if the operation hasn't been cancelled.
This commit is contained in:
António Fernandes 2024-06-02 17:18:55 +01:00
parent 12980ee1bd
commit 16b81477b3

View file

@ -51,7 +51,6 @@ network_mount_callback (GObject *source_object,
GAsyncResult *result,
gpointer data)
{
NautilusInternalPlaceFile *self = NAUTILUS_INTERNAL_PLACE_FILE (data);
g_autoptr (GError) error = NULL;
(void) g_file_mount_enclosing_volume_finish (G_FILE (source_object), result, &error);
@ -60,6 +59,8 @@ network_mount_callback (GObject *source_object,
return;
}
NautilusInternalPlaceFile *self = NAUTILUS_INTERNAL_PLACE_FILE (data);
/* Clear cancellable and steal callbacks list because call_when_ready() may
* be called again inside the `for` loop. */
g_clear_object (&self->network_mount_cancellable);