rpms/gnome-menus/devel gnome-menus-2.11.91-fix-notifies-memory-corruption.patch, NONE, 1.1 .cvsignore, 1.6, 1.7 gnome-menus.spec, 1.14, 1.15 sources, 1.6, 1.7

fedora-cvs-commits at redhat.com fedora-cvs-commits at redhat.com
Tue Aug 16 13:44:42 UTC 2005


Author: markmc

Update of /cvs/dist/rpms/gnome-menus/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv25618

Modified Files:
	.cvsignore gnome-menus.spec sources 
Added Files:
	gnome-menus-2.11.91-fix-notifies-memory-corruption.patch 
Log Message:
* Tue Aug 16 2005 Mark McLoughlin <markmc at redhat.com> 2.11.91-1
- Update to 2.11.91
- Backport patch from HEAD to hopefully fix crasher (rh #165977)


gnome-menus-2.11.91-fix-notifies-memory-corruption.patch:
 ChangeLog              |   19 ++++++++++++++++
 libmenu/menu-monitor.c |   55 ++++++++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 69 insertions(+), 5 deletions(-)

--- NEW FILE gnome-menus-2.11.91-fix-notifies-memory-corruption.patch ---
--- gnome-menus-2.11.91/ChangeLog.fix-notifies-memory-corruption	2005-08-09 08:28:27.000000000 -0400
+++ gnome-menus-2.11.91/ChangeLog	2005-08-16 09:32:21.000000000 -0400
@@ -0,0 +1,19 @@
+2005-08-12  Mark McLoughlin  <mark at skynet.ie>
+
+	Fixes bug #313232 - memory corruption issue where notifies
+	were being removed from under us as we walked the list of
+	notifies.
+
+	* libmenu/menu-monitor.c:
+	(menu_monitor_notify_ref),
+	(menu_monitor_notify_unref): make MenuMonitorNotify refcounted.
+	(menu_monitor_add_notify): set initial refcount.
+	(menu_monitor_remove_notify): when removing the notify, unset
+	the callback pointer and unref.
+	(invoke_notifies): make a copy of the notifies list and
+	ref each notify before invoking the callbacks - callbacks
+	may cause arbitrary notifies to be removed as we walk the
+	list.
+	(menu_monitor_unref): unref each of the notifies rather
+	than freeing them.
+
--- gnome-menus-2.11.91/libmenu/menu-monitor.c.fix-notifies-memory-corruption	2005-07-20 10:59:50.000000000 -0400
+++ gnome-menus-2.11.91/libmenu/menu-monitor.c	2005-08-16 09:32:21.000000000 -0400
@@ -47,6 +47,7 @@
 {
   MenuMonitorNotifyFunc notify_func;
   gpointer              user_data;
+  guint                 refcount;
 } MenuMonitorNotify;
 
 #ifdef HAVE_FAM
@@ -67,23 +68,40 @@
 static guint          fam_io_watch = 0;
 static guint          events_idle_handler = 0;
 
+static MenuMonitorNotify *menu_monitor_notify_ref   (MenuMonitorNotify *notify);
+static void               menu_monitor_notify_unref (MenuMonitorNotify *notify);
+
 static void
 invoke_notifies (MenuMonitor      *monitor,
 		 MenuMonitorEvent  event,
 		 const char       *path)
 {
+  GSList *copy;
   GSList *tmp;
 
-  tmp = monitor->notifies;
+  copy = g_slist_copy (monitor->notifies);
+  g_slist_foreach (copy,
+		   (GFunc) menu_monitor_notify_ref,
+		   NULL);
+		   
+
+  tmp = copy;
   while (tmp != NULL)
     {
       MenuMonitorNotify *notify = tmp->data;
-      GSList            *next    = tmp->next;
+      GSList            *next   = tmp->next;
 
-      notify->notify_func (monitor, event, path, notify->user_data);
+      if (notify->notify_func)
+	{
+	  notify->notify_func (monitor, event, path, notify->user_data);
+	}
+
+      menu_monitor_notify_unref (notify);
 
       tmp = next;
     }
+
+  g_slist_free (copy);
 }
 
 static void
@@ -516,7 +534,7 @@
 
   unregister_monitor_with_fam (monitor);
 
-  g_slist_foreach (monitor->notifies, (GFunc) g_free, NULL);
+  g_slist_foreach (monitor->notifies, (GFunc) menu_monitor_notify_unref, NULL);
   g_slist_free (monitor->notifies);
   monitor->notifies = NULL;
 
@@ -540,6 +558,29 @@
   return monitor->path;
 }
 
+static MenuMonitorNotify *
+menu_monitor_notify_ref (MenuMonitorNotify *notify)
+{
+  g_return_val_if_fail (notify != NULL, NULL);
+  g_return_val_if_fail (notify->refcount > 0, NULL);
+
+  notify->refcount++;
+
+  return notify;
+}
+
+static void
+menu_monitor_notify_unref (MenuMonitorNotify *notify)
+{
+  g_return_if_fail (notify != NULL);
+  g_return_if_fail (notify->refcount > 0);
+
+  if (--notify->refcount > 0)
+    return;
+
+  g_free (notify);
+}
+
 void
 menu_monitor_add_notify (MenuMonitor           *monitor,
 			 MenuMonitorNotifyFunc  notify_func,
@@ -568,6 +609,7 @@
       notify              = g_new0 (MenuMonitorNotify, 1);
       notify->notify_func = notify_func;
       notify->user_data   = user_data;
+      notify->refcount    = 1;
 
       monitor->notifies = g_slist_append (monitor->notifies, notify);
     }
@@ -589,8 +631,11 @@
       if (notify->notify_func == notify_func &&
           notify->user_data   == user_data)
         {
+	  notify->notify_func = NULL;
+	  notify->user_data   = NULL;
+          menu_monitor_notify_unref (notify);
+
           monitor->notifies = g_slist_delete_link (monitor->notifies, tmp);
-          g_free (notify);
         }
 
       tmp = next;


Index: .cvsignore
===================================================================
RCS file: /cvs/dist/rpms/gnome-menus/devel/.cvsignore,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- .cvsignore	3 Aug 2005 19:51:25 -0000	1.6
+++ .cvsignore	16 Aug 2005 13:44:40 -0000	1.7
@@ -1 +1 @@
-gnome-menus-2.11.90.tar.bz2
+gnome-menus-2.11.91.tar.bz2


Index: gnome-menus.spec
===================================================================
RCS file: /cvs/dist/rpms/gnome-menus/devel/gnome-menus.spec,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- gnome-menus.spec	3 Aug 2005 19:48:57 -0000	1.14
+++ gnome-menus.spec	16 Aug 2005 13:44:40 -0000	1.15
@@ -6,7 +6,7 @@
 
 Summary:  A menu system for the GNOME project
 Name: gnome-menus
-Version: 2.11.90
+Version: 2.11.91
 Release: 1
 License: LGPL
 Group: System Environment/Libraries
@@ -18,6 +18,8 @@
 BuildRequires: glib2-devel >= 2.6.0
 BuildRequires: %{python}-devel >= 2.3.0
 
+Patch0: gnome-menus-2.11.91-fix-notifies-memory-corruption.patch
+
 %description
 gnome-menus is an implementation of the draft "Desktop
 Menu Specification" from freedesktop.org. This package
@@ -37,6 +39,8 @@
 %prep
 %setup -q
 
+%patch0 -p1 -b .fix-notifies-memory-corruption
+
 %build
 %configure \
 %if %{enable_debugging}
@@ -76,6 +80,7 @@
 %{_bindir}/gmenu-simple-editor
 %{_libdir}/python*/site-packages/GMenuSimpleEditor/*
 %{_datadir}/gnome-menus/glade/gmenu-simple-editor.glade
+%{_datadir}/applications/gmenu-simple-editor.desktop
 
 %files devel
 %defattr(-, root, root)
@@ -86,6 +91,10 @@
 %{_bindir}/gnome-menu-spec-test
 
 %changelog
+* Tue Aug 16 2005 Mark McLoughlin <markmc at redhat.com> 2.11.91-1
+- Update to 2.11.91
+- Backport patch from HEAD to hopefully fix crasher (rh #165977)
+
 * Wed Aug 03 2005 Ray Strode <rstrode at redhat.com> - 2.11.90-1
 - Update to upstream version 2.11.90
 


Index: sources
===================================================================
RCS file: /cvs/dist/rpms/gnome-menus/devel/sources,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- sources	3 Aug 2005 19:51:25 -0000	1.6
+++ sources	16 Aug 2005 13:44:40 -0000	1.7
@@ -1 +1 @@
-fb9f887d75a5f945e541fcce45bc6f32  gnome-menus-2.11.90.tar.bz2
+7e90fda926e28dc31043281562a83da4  gnome-menus-2.11.91.tar.bz2




More information about the fedora-cvs-commits mailing list