/pidgin/main: e9a51548cdcb: Merged in xhaakon/pidgin (pull reque...

Gary Kramlich grim at reaperworld.com
Thu Jun 16 18:09:55 EDT 2016


Changeset: e9a51548cdcb0c2a61ed4bff6c688e7d2e81aad2
Author:	 Gary Kramlich <grim at reaperworld.com>
Date:	 2016-06-16 17:09 -0500
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/e9a51548cdcb

Description:

Merged in xhaakon/pidgin (pull request #74)

Fix valgrind issues in media code

diffstat:

 libpurple/mediamanager.c |  39 ++++++++++++++++++++++++++++++++++++---
 1 files changed, 36 insertions(+), 3 deletions(-)

diffs (80 lines):

diff --git a/libpurple/mediamanager.c b/libpurple/mediamanager.c
--- a/libpurple/mediamanager.c
+++ b/libpurple/mediamanager.c
@@ -458,14 +458,18 @@ purple_media_manager_remove_media(Purple
 
 #ifdef HAVE_MEDIA_APPLICATION
 		g_mutex_lock (&manager->priv->appdata_mutex);
-		for (list = manager->priv->appdata_info; list; list = list->next) {
+		list = manager->priv->appdata_info;
+		while (list) {
 			PurpleMediaAppDataInfo *info = list->data;
+			GList *next = list->next;
 
 			if (info->media == media) {
 				manager->priv->appdata_info = g_list_delete_link (
 					manager->priv->appdata_info, list);
 				free_appdata_info_locked (info);
 			}
+
+			list = next;
 		}
 		g_mutex_unlock (&manager->priv->appdata_mutex);
 #endif
@@ -525,9 +529,24 @@ purple_media_manager_get_private_media_b
 static void
 free_appdata_info_locked (PurpleMediaAppDataInfo *info)
 {
+	GstAppSrcCallbacks null_src_cb = { NULL, NULL, NULL, { NULL } };
+	GstAppSinkCallbacks null_sink_cb = { NULL, NULL, NULL , { NULL } };
+
 	if (info->notify)
 		info->notify (info->user_data);
 
+	info->media = NULL;
+	if (info->appsrc) {
+		/* Will call appsrc_destroyed. */
+		gst_app_src_set_callbacks (info->appsrc, &null_src_cb,
+				NULL, NULL);
+	}
+	if (info->appsink) {
+		/* Will call appsink_destroyed. */
+		gst_app_sink_set_callbacks (info->appsink, &null_sink_cb,
+				NULL, NULL);
+	}
+
 	/* Make sure no other thread is using the structure */
 	g_free (info->session_id);
 	g_free (info->participant);
@@ -822,7 +841,14 @@ appsrc_seek_data (GstAppSrc *appsrc, gui
 static void
 appsrc_destroyed (PurpleMediaAppDataInfo *info)
 {
-	PurpleMediaManager *manager = purple_media_manager_get ();
+	PurpleMediaManager *manager;
+
+	if (!info->media) {
+		/* PurpleMediaAppDataInfo is being freed. Return at once. */
+		return;
+	}
+
+	manager = purple_media_manager_get ();
 
 	g_mutex_lock (&manager->priv->appdata_mutex);
 	info->appsrc = NULL;
@@ -980,7 +1006,14 @@ appsink_new_sample (GstAppSink *appsink,
 static void
 appsink_destroyed (PurpleMediaAppDataInfo *info)
 {
-	PurpleMediaManager *manager = purple_media_manager_get ();
+	PurpleMediaManager *manager;
+
+	if (!info->media) {
+		/* PurpleMediaAppDataInfo is being freed. Return at once. */
+		return;
+	}
+
+	manager = purple_media_manager_get ();
 
 	g_mutex_lock (&manager->priv->appdata_mutex);
 	info->appsink = NULL;



More information about the Commits mailing list