From 1e68cdbe2d837594d8258a026500a0b84a57e792 Mon Sep 17 00:00:00 2001
From: Spencer Lommel <118965093+SpencerLommel@users.noreply.github.com>
Date: Wed, 16 Apr 2025 08:10:16 -0500
Subject: [PATCH] Cvc null check profile (#254)

* null checks on mixer profile

* style fix to conform with the rest of the code
---
 libcvc/gvc-mixer-control.c   | 5 +++++
 libcvc/gvc-mixer-ui-device.c | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/libcvc/gvc-mixer-control.c b/libcvc/gvc-mixer-control.c
index b385461..acd8d9b 100644
--- a/libcvc/gvc-mixer-control.c
+++ b/libcvc/gvc-mixer-control.c
@@ -549,6 +549,11 @@ gvc_mixer_control_change_profile_on_selected_device (GvcMixerControl  *control,
         g_object_get (G_OBJECT (device), "card", &card, NULL);
         current_profile = gvc_mixer_card_get_profile (card);
 
+        if (!current_profile) {
+          g_warning("gvc_mixer_card_get_profile() returned NULL for card %p", card);
+          return FALSE;
+        }
+        
         if (current_profile)
                 best_profile = gvc_mixer_ui_device_get_best_profile (device, profile, current_profile->profile);
         else
diff --git a/libcvc/gvc-mixer-ui-device.c b/libcvc/gvc-mixer-ui-device.c
index a0567fc..a6b7882 100644
--- a/libcvc/gvc-mixer-ui-device.c
+++ b/libcvc/gvc-mixer-ui-device.c
@@ -557,6 +557,11 @@ gvc_mixer_ui_device_get_active_profile (GvcMixerUIDevice* device)
         }
 
         profile = gvc_mixer_card_get_profile (device->priv->card);
+        if (!profile) {
+                g_warning ("gvc_mixer_card_get_profile() returned NULL for card %p", device->priv->card);
+                return NULL;
+        }
+        
         return gvc_mixer_ui_device_get_matching_profile (device, profile->profile);
 }
 
