Bug 666551-Fix a few dangling pointers

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.
This commit is contained in:
rodrigorivascosta 2011-12-22 10:48:09 +08:00 committed by Chun-wei Fan
parent 76bc1ab280
commit 1b03377442

View File

@ -867,6 +867,10 @@ g_thread_xp_SleepConditionVariableSRW (gpointer cond,
EnterCriticalSection (&g_thread_xp_lock); EnterCriticalSection (&g_thread_xp_lock);
if (waiter->my_owner) 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 = waiter->next;
waiter->my_owner = NULL; waiter->my_owner = NULL;
} }
@ -887,6 +891,7 @@ g_thread_xp_WakeConditionVariable (gpointer cond)
waiter = cv->first; waiter = cv->first;
if (waiter != NULL) if (waiter != NULL)
{ {
waiter->my_owner = NULL;
cv->first = waiter->next; cv->first = waiter->next;
if (cv->first != NULL) if (cv->first != NULL)
cv->first->my_owner = &cv->first; cv->first->my_owner = &cv->first;