mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Replace the implementations of NSFastEnumeration in NSConcrete{Hash,Map}Table with ones that work and don't cause people to dereference pointers that are set to random integer values.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@33713 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
8a88a7f66e
commit
6cdbd621be
2 changed files with 6 additions and 62 deletions
|
@ -934,37 +934,9 @@ const NSHashTableCallBacks NSPointerToStructHashCallBacks =
|
|||
objects: (id*)stackbuf
|
||||
count: (NSUInteger)len
|
||||
{
|
||||
NSInteger count;
|
||||
NSHashEnumerator enumerator;
|
||||
|
||||
state->mutationsPtr = (unsigned long *)version;
|
||||
if (state->state == 0 && state->extra[0] == 0)
|
||||
{
|
||||
enumerator = GSIMapEnumeratorForMap(self);
|
||||
}
|
||||
else
|
||||
{
|
||||
enumerator.map = self;
|
||||
enumerator.node = (GSIMapNode)(uintptr_t)state->state;
|
||||
enumerator.bucket = state->extra[0];
|
||||
}
|
||||
for (count = 0; count < len; count++)
|
||||
{
|
||||
GSIMapNode node = GSIMapEnumeratorNextNode(&enumerator);
|
||||
|
||||
if (node == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
stackbuf[count] = node->key.obj;
|
||||
}
|
||||
}
|
||||
state->state = (unsigned long)(uintptr_t)enumerator.node;
|
||||
state->extra[0] = enumerator.bucket;
|
||||
state->itemsPtr = stackbuf;
|
||||
return count;
|
||||
state->mutationsPtr = (unsigned long *)&version;
|
||||
return GSIMapCountByEnumeratingWithStateObjectsCount
|
||||
(self, state, stackbuf, len);
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
|
|
|
@ -1210,37 +1210,9 @@ const NSMapTableValueCallBacks NSOwnedPointerMapValueCallBacks =
|
|||
objects: (id*)stackbuf
|
||||
count: (NSUInteger)len
|
||||
{
|
||||
NSInteger count;
|
||||
NSMapEnumerator enumerator;
|
||||
|
||||
state->mutationsPtr = (unsigned long *)version;
|
||||
if (state->state == 0 && state->extra[0] == 0)
|
||||
{
|
||||
enumerator = GSIMapEnumeratorForMap(self);
|
||||
}
|
||||
else
|
||||
{
|
||||
enumerator.map = self;
|
||||
enumerator.node = (GSIMapNode)(uintptr_t)state->state;
|
||||
enumerator.bucket = state->extra[0];
|
||||
}
|
||||
for (count = 0; count < len; count++)
|
||||
{
|
||||
GSIMapNode node = GSIMapEnumeratorNextNode(&enumerator);
|
||||
|
||||
if (node == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
stackbuf[count] = node->key.obj;
|
||||
}
|
||||
}
|
||||
state->state = (unsigned long)(uintptr_t)enumerator.node;
|
||||
state->extra[0] = enumerator.bucket;
|
||||
state->itemsPtr = stackbuf;
|
||||
return count;
|
||||
state->mutationsPtr = (unsigned long *)&version;
|
||||
return GSIMapCountByEnumeratingWithStateObjectsCount
|
||||
(self, state, stackbuf, len);
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
|
|
Loading…
Reference in a new issue