mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 08:26:27 +00:00
([NSGArray -initWithObjects:count:]): Raise exception for nil objects.
([NSGArray -objectAtIndex:]): Raise exception when index too high. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@630 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
7c98affe14
commit
a1e01df688
1 changed files with 10 additions and 1 deletions
|
@ -26,6 +26,7 @@
|
|||
#include <objects/behavior.h>
|
||||
#include <objects/Array.h>
|
||||
#include <objects/ArrayPrivate.h>
|
||||
#include <Foundation/NSException.h>
|
||||
|
||||
@implementation NSGArray
|
||||
|
||||
|
@ -43,6 +44,12 @@
|
|||
/* This is the designated initializer for NSArray. */
|
||||
- initWithObjects: (id*)objects count: (unsigned)count
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
if (objects[i] == nil)
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"Tried to add nil"];
|
||||
/* "super" call into IndexedCollection */
|
||||
#if 1
|
||||
CALL_METHOD_IN_CLASS([IndexedCollection class], initWithType:,
|
||||
|
@ -76,7 +83,9 @@
|
|||
|
||||
- objectAtIndex: (unsigned)index
|
||||
{
|
||||
assert(index < _count); /* xxx should raise NSException instead */
|
||||
if (index < _count)
|
||||
[NSException raise:NSRangeException
|
||||
format:@"Index out of bounds"];
|
||||
return _contents_array[index].id_u;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue