/pidgin/main: 457ce85caedc: mediamanager: fix invalid memory read

Jakub Adam jakub.adam at ktknet.cz
Thu Jun 16 18:09:55 EDT 2016


Changeset: 457ce85caedc607f61a8f361df35928d0c9b6fc5
Author:	 Jakub Adam <jakub.adam at ktknet.cz>
Date:	 2016-06-10 16:47 +0200
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/457ce85caedc

Description:

mediamanager: fix invalid memory read

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

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
@@ -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



More information about the Commits mailing list