Throw an exception for -1 indexes in CPArray objectAtIndex:

This commit is contained in:
Ross Boucher committed 2009-12-02 19:19:18 -08:00
1 parent 2120e9cf2a
commit e6d86eaa9b
1 file changed
+2 -2
+2 -2
View File
@@ -521,8 +521,8 @@
*/
- (id)objectAtIndex:(int)anIndex
{
if (anIndex >= length)
[CPException raise:CPRangeException reason:@"index (" + anIndex + @") beyond bounds (" + length + @")"];
if (anIndex >= length || anIndex < 0)
[CPException raise:CPRangeException reason:@"index (" + anIndex + @") out of bounds (0 - " + length + @")"];
return self[anIndex];
}