/pidgin/main: d9aac4128ad2: mediamanager: fix invalid memory read

Jakub Adam jakub.adam at ktknet.cz
Sat Jun 18 22:10:09 EDT 2016


Changeset: d9aac4128ad2934e70ff7d04a01a1c9cca23d3ca
Author:	 Jakub Adam <jakub.adam at ktknet.cz>
Date:	 2016-06-10 16:47 +0200
Branch:	 release-2.x.y
URL: https://hg.pidgin.im/pidgin/main/rev/d9aac4128ad2

Description:

mediamanager: fix invalid memory read

Loop was accessing 'next' pointer in already deallocated GList item.
Reported by Valgrind.

Backport of Pidgin 3 commit 457ce85caedc.

diffstat:

 libpurple/mediamanager.c |  6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diffs (23 lines):

diff --git a/libpurple/mediamanager.c b/libpurple/mediamanager.c
--- a/libpurple/mediamanager.c
+++ b/libpurple/mediamanager.c
@@ -491,14 +491,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



More information about the Commits mailing list