[tracker/rss-enclosures] Fixes GB#615313 - Avoid Invalid Read when iterating INotifyHandle list



commit 954a23395d5d0449b3f8ab27ab313b37a3416319
Author: Aleksander Morgado <aleksander lanedo com>
Date:   Mon Apr 12 17:24:41 2010 +0100

    Fixes GB#615313 - Avoid Invalid Read when iterating INotifyHandle list

 src/libinotify/inotify-monitor.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/src/libinotify/inotify-monitor.c b/src/libinotify/inotify-monitor.c
index ce9317f..b120352 100644
--- a/src/libinotify/inotify-monitor.c
+++ b/src/libinotify/inotify-monitor.c
@@ -46,11 +46,17 @@ process_one_event( struct inotify_event *ine )
 
   inotify_debug( "Got one event" );
 
-  for( list = inotify_listhash_get( ine->wd ); list; list = list->next )
+  list = inotify_listhash_get( ine->wd );
+  while (list)
   {
+    GSList *next = list->next;
     inotify_debug( "  dispatch to %p", list->data );
     inotify_handle_invoke_callback( list->data, filename,
 				    ine->mask, ine->cookie );
+    /* Note that AFTER executing the callback, both the list element and the
+     *  INotifyHandle may already be disposed. So, the pointer to the next
+     *  list element should have been stored before calling the callback */
+    list = next;
   }
 
   if( ine->mask & IN_IGNORED )



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]