Bug 666551-Fix a few dangling pointers
authorrodrigorivascosta <rodrigorivascosta@gmail.com>
Thu, 22 Dec 2011 02:48:09 +0000 (10:48 +0800)
committerChun-wei Fan <fanchunwei@src.gnome.org>
Thu, 22 Dec 2011 02:51:31 +0000 (10:51 +0800)
When removing an item from the list, check the next one's my_owner,
and fix it accordingly. And take this case into account when last
of the list is deleted.

Also, assign NULL to 'my_owner' in g_thread_xp_WakeConditionVariable.

glib/gthread-win32.c

index 3ec908d..94a56e2 100644 (file)
@@ -867,6 +867,10 @@ g_thread_xp_SleepConditionVariableSRW (gpointer cond,
       EnterCriticalSection (&g_thread_xp_lock);
       if (waiter->my_owner)
         {
+          if (waiter->next)
+            waiter->next->my_owner = waiter->my_owner;
+          else
+            cv->last_ptr = waiter->my_owner;
           *waiter->my_owner = waiter->next;
           waiter->my_owner = NULL;
         }
@@ -887,6 +891,7 @@ g_thread_xp_WakeConditionVariable (gpointer cond)
   waiter = cv->first;
   if (waiter != NULL)
     {
+      waiter->my_owner = NULL;
       cv->first = waiter->next;
       if (cv->first != NULL)
         cv->first->my_owner = &cv->first;