[libgnome-volume-control] mixer-control: fix gvc_mixer_card_set_profiles API usage



commit 8e7a5a4c3e51007ce6579292642517e3d3eb9c50
Author: Pauli Virtanen <pav iki fi>
Date:   Wed Jan 12 20:07:44 2022 +0200

    mixer-control: fix gvc_mixer_card_set_profiles API usage
    
    In update_card, profile_list is incorrectly used also after its
    ownership is transferred to the GvcMixerCard.  In practice, this causes
    e.g. some profiles to go missing due to the list head being clobbered.
    
    Fix this by calling gvc_mixer_card_set_profiles only after profiles_list
    is no longer used for any other purpose.

 gvc-mixer-control.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/gvc-mixer-control.c b/gvc-mixer-control.c
index 45c729c..6218a1b 100644
--- a/gvc-mixer-control.c
+++ b/gvc-mixer-control.c
@@ -2590,7 +2590,6 @@ update_card (GvcMixerControl      *control,
                 }
                 card = gvc_mixer_card_new (control->priv->pa_context,
                                            info->index);
-                gvc_mixer_card_set_profiles (card, profile_list);
 
                 for (i = 0; i < info->n_ports; i++) {
                         GvcMixerCardPort *port;
@@ -2604,6 +2603,8 @@ update_card (GvcMixerControl      *control,
                         port->profiles = determine_profiles_for_port (info->ports[i], profile_list);
                         port_list = g_list_prepend (port_list, port);
                 }
+
+                gvc_mixer_card_set_profiles (card, profile_list);
                 gvc_mixer_card_set_ports (card, port_list);
                 is_new = TRUE;
         }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]