Fixes for bug #28104 by Wolfgang Lux and Richard Frith-Macdonald

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@31171 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2010-08-17 07:13:05 +00:00
parent a17d3b1466
commit fd9e60c1af
2 changed files with 22 additions and 13 deletions

View file

@ -1,3 +1,16 @@
2010-08-17 Wolfgang Lux <wolfgang.lux@gmail.com>
* Source/NSNotificationQueue.m: remove_from_queue_no_release()
Add assertions instead of existing hack when removing an item
from a corrupted list.
2010-08-17 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSNotificationQueue.m: notify() .. buffer notifications
in a mutable array and remove from list before posting them.
Prevents re-entrancy problems and avoids memory leak when an exception
occurs during posting.
2010-08-13 Eric Wasylishen <ewasylishen@gmail.com>
* Headers/Foundation/NSLocale.h:

View file

@ -197,11 +197,8 @@ remove_from_queue_no_release(NSNotificationQueueList *queue,
}
else
{
NSCAssert(queue->tail == item, @"tail item not at tail of queue!");
queue->tail = item->prev;
if (item->prev)
{
item->prev->next = NULL;
}
}
if (item->prev)
@ -210,11 +207,8 @@ remove_from_queue_no_release(NSNotificationQueueList *queue,
}
else
{
NSCAssert(queue->head == item, @"head item not at head of queue!");
queue->head = item->next;
if (item->next)
{
item->next->prev = NULL;
}
}
}
@ -615,20 +609,22 @@ notify(NSNotificationCenter *center, NSNotificationQueueList *list,
if (len > 0)
{
NSMutableArray *ma = [NSMutableArray arrayWithCapacity: len];
for (pos = 0; pos < len; pos++)
{
NSNotification *notification;
item = ptr[pos];
notification = RETAIN(item->notification);
[ma addObject: item->notification];
remove_from_queue(list, item, zone);
[center postNotification: notification];
RELEASE(notification);
}
if (allocated)
{
NSZoneFree(NSDefaultMallocZone(), ptr);
}
for (pos = 0; pos < len; pos++)
{
[center postNotification: [ma objectAtIndex: pos]];
}
}
}