diff options
author | Christophe Fergeau <cfergeau@redhat.com> | 2013-04-10 16:14:56 +0200 |
---|---|---|
committer | Christophe Fergeau <cfergeau@redhat.com> | 2013-04-10 16:16:18 +0200 |
commit | c868defbae60db0fa4054334a8d7248dd05140ef (patch) | |
tree | 97d6639e445c7834c5210c95eecb3ae7eed8fcfd | |
parent | b717d3c29529fa8c36c57c1ff5ec84c82a910247 (diff) |
egg-play-preview: Fix leak when receiving multiple tag messages
If gstreamer emits multiple time the signal indicating tags have
been found, the previous value for title/album/artist will be leaked.
Free it before overwriting it.
-rw-r--r-- | src/egg-play-preview.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/egg-play-preview.c b/src/egg-play-preview.c index 9c664d6..b9e6918 100644 --- a/src/egg-play-preview.c +++ b/src/egg-play-preview.c @@ -571,6 +571,9 @@ _process_bus_messages (GstBus *bus, GstMessage *msg, EggPlayPreview *play_previe GstFormat format = GST_FORMAT_TIME; GstTagList *tag_list; gint64 duration; + gchar *title; + gchar *artist; + gchar *album; GstState state; GstStateChangeReturn result; @@ -596,13 +599,21 @@ _process_bus_messages (GstBus *bus, GstMessage *msg, EggPlayPreview *play_previe case GST_MESSAGE_TAG: gst_message_parse_tag (msg, &tag_list); - gst_tag_list_get_string (tag_list, GST_TAG_TITLE, &priv->title); - gst_tag_list_get_string (tag_list, GST_TAG_ARTIST, &priv->artist); - gst_tag_list_get_string (tag_list, GST_TAG_ALBUM, &priv->album); - - g_object_notify (G_OBJECT (play_preview), "title"); - g_object_notify (G_OBJECT (play_preview), "artist"); - g_object_notify (G_OBJECT (play_preview), "album"); + if (gst_tag_list_get_string (tag_list, GST_TAG_TITLE, &title)) { + g_free(priv->title); + priv->title = title; + g_object_notify (G_OBJECT (play_preview), "title"); + } + if (gst_tag_list_get_string (tag_list, GST_TAG_ARTIST, &artist)) { + g_free(priv->artist); + priv->artist = artist; + g_object_notify (G_OBJECT (play_preview), "artist"); + } + if (gst_tag_list_get_string (tag_list, GST_TAG_ALBUM, &album)) { + g_free(priv->album); + priv->album = album; + g_object_notify (G_OBJECT (play_preview), "album"); + } _ui_update_tags (play_preview); break; |