play: Fix stream id leaks on initial stream selection
authorSebastian Dröge <sebastian@centricular.com>
Sat, 28 Dec 2024 11:26:18 +0000 (13:26 +0200)
committerSebastian Dröge <sebastian@centricular.com>
Sat, 28 Dec 2024 11:51:50 +0000 (13:51 +0200)
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7650>

subprojects/gst-plugins-bad/gst-libs/gst/play/gstplay.c

index 5cd9170a9fe9d39b29f6ea459a3d5e028bfed43c..ef93821451b3725a0e4fd5d430ce9598b336a1f5 100644 (file)
@@ -1667,12 +1667,15 @@ stream_collection_cb (G_GNUC_UNUSED GstBus * bus, GstMessage * msg,
       const gchar *stream_id = gst_stream_get_stream_id (stream);
 
       if ((stream_type & GST_STREAM_TYPE_AUDIO) && select_audio) {
+        g_free (self->audio_sid);
         self->audio_sid = g_strdup (stream_id);
         select_audio = FALSE;
       } else if ((stream_type & GST_STREAM_TYPE_VIDEO) && select_video) {
+        g_free (self->video_sid);
         self->video_sid = g_strdup (stream_id);
         select_video = FALSE;
       } else if ((stream_type & GST_STREAM_TYPE_TEXT) && select_subtitle) {
+        g_free (self->subtitle_sid);
         self->subtitle_sid = g_strdup (stream_id);
         select_subtitle = FALSE;
       }
@@ -1718,9 +1721,11 @@ streams_selected_cb (G_GNUC_UNUSED GstBus * bus, GstMessage * msg,
     GstStreamType stream_type;
     const gchar *stream_id;
     gchar **current_sid;
+
     stream = gst_message_streams_selected_get_stream (msg, i);
     stream_type = gst_stream_get_stream_type (stream);
     stream_id = gst_stream_get_stream_id (stream);
+
     if (stream_type & GST_STREAM_TYPE_AUDIO)
       current_sid = &self->audio_sid;
     else if (stream_type & GST_STREAM_TYPE_VIDEO)