From 74bb480753d1a9dc53a2d0b7f7d6997e309315a2 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Tue, 22 Nov 2022 12:05:27 +0100 Subject: [PATCH] sound player: Don't unref undefined fields If the sound player feature is disabled, none of those fields are instantiated which causes the crash reported in #2451 Also switch to using g_clear_pointer while we are at it Fixes https://gitlab.gnome.org/GNOME/mutter/-/issues/2451 Part-of: --- src/core/meta-sound-player.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/core/meta-sound-player.c b/src/core/meta-sound-player.c index 29f831bab..3cc2f26b0 100644 --- a/src/core/meta-sound-player.c +++ b/src/core/meta-sound-player.c @@ -34,12 +34,12 @@ struct _MetaSoundPlayer { GObject parent; +#ifdef HAVE_SOUND_PLAYER GThreadPool *queue; GSettings *settings; -#ifdef HAVE_SOUND_PLAYER ca_context *context; -#endif uint32_t id_pool; +#endif }; #ifdef HAVE_SOUND_PLAYER @@ -71,13 +71,12 @@ G_DEFINE_TYPE (MetaSoundPlayer, meta_sound_player, G_TYPE_OBJECT) static void meta_sound_player_finalize (GObject *object) { +#ifdef HAVE_SOUND_PLAYER MetaSoundPlayer *player = META_SOUND_PLAYER (object); - g_object_unref (player->settings); + g_clear_object (&player->settings); g_thread_pool_free (player->queue, FALSE, TRUE); - -#ifdef HAVE_SOUND_PLAYER - ca_context_destroy (player->context); + g_clear_pointer (&player->context, ca_context_destroy); #endif G_OBJECT_CLASS (meta_sound_player_parent_class)->finalize (object);