Check for nil when replacing object in array.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@26525 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2008-05-14 09:31:33 +00:00
parent c6512d3d22
commit b90ea547bc
2 changed files with 19 additions and 0 deletions

View file

@ -714,6 +714,21 @@ static Class GSInlineArrayClass;
{
[self _raiseRangeExceptionWithIndex: index from: _cmd];
}
if (!anObject)
{
NSException *exception;
NSDictionary *info;
info = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithUnsignedInt: index], @"Index",
_contents_array[index], @"OLdObject",
self, @"Array", nil, nil];
exception = [NSException exceptionWithName: NSInvalidArgumentException
reason: @"Tried to replace object in array with nil"
userInfo: info];
[exception raise];
}
/*
* Swap objects in order so that there is always a valid object in the
* array in case a retain or release causes an exception.