Fix obscure memory management issues

This commit is contained in:
rfm 2024-06-19 15:28:48 +01:00
parent 1c2b81d724
commit 235bb21df3
3 changed files with 10 additions and 13 deletions

View file

@ -237,21 +237,14 @@ static SEL objSel;
if (isProxy == YES)
{
k = [e nextObject];
if (nil == (k = [e nextObject])) break;
o = [other objectForKey: k];
}
else
{
k = (*nxtObj)(e, nxtSel);
if (nil == (k = (*nxtObj)(e, nxtSel))) break;
o = (*otherObj)(other, objSel, k);
}
k = [k copyWithZone: z];
if (k == nil)
{
DESTROY(self);
[NSException raise: NSInvalidArgumentException
format: @"Tried to init dictionary with nil key"];
}
if (shouldCopy)
{
o = [o copyWithZone: z];
@ -275,7 +268,8 @@ static SEL objSel;
}
else
{
GSIMapAddPairNoRetain(&map, (GSIMapKey)k, (GSIMapVal)o);
GSIMapAddPair(&map, (GSIMapKey)k, (GSIMapVal)o);
RELEASE(o);
}
}
}

View file

@ -253,12 +253,15 @@ static NSMapTable *globalClassMap = 0;
if (_delegate != nil)
{
r = [_delegate unarchiver: self didDecodeObject: o];
if (r != o)
/* Apple documentation says that the delegate may return nil to
* indicate that the decoded objects should not be changed.
*/
if (r != nil && r != o)
{
[_delegate unarchiver: self
willReplaceObject: o
withObject: r];
o = r;
o = RETAIN(r);
GSIArraySetItemAtIndex(_objMap, (GSIArrayItem)o, index);
}
}

View file

@ -1012,7 +1012,7 @@ NSLog(@"_processTag <%@%@ %@>", flag?@"/": @"", tag, attributes);
}
else
{
entity = @""; // not resolved
ASSIGN(entity, @""); // not resolved
}
return entity;
}