mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-10-27 02:25:36 +00:00
Argument check CPIndexSet indexSetWithIndex:.
Without this check, an index set could be initialised with NaN which would later lead to an infinite loop when enumerating the index set. This error makes the error early and explicit.
This commit is contained in:
1 parent
4021eae002
commit
821961fc26
2 files changed
+6
No files matched your search
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
|
||||
#include "CPRange.h"
|
||||
#include "Foundation.h"
|
||||
|
||||
@import "CPArray.j"
|
||||
@import "CPObject.j"
|
||||
@@ -79,6 +80,10 @@
|
||||
*/
|
||||
- (id)initWithIndex:(CPInteger)anIndex
|
||||
{
|
||||
if (!_IS_NUMERIC(anIndex))
|
||||
[CPException raise:CPInvalidArgumentException
|
||||
reason:"Invalid index"];
|
||||
|
||||
return [self initWithIndexesInRange:_CPMakeRange(anIndex, 1)];
|
||||
}
|
||||
|
||||
|
||||
@@ -202,6 +202,7 @@ function descriptionWithoutEntity(aString)
|
||||
[self assertTrue:[[CPIndexSet indexSetWithIndex:1] containsIndex:1]];
|
||||
[self assertTrue:[[CPIndexSet indexSetWithIndex:0] containsIndex:0]];
|
||||
[self assertFalse:[[CPIndexSet indexSetWithIndex:0] containsIndex:1]];
|
||||
[self assertThrows:function() { [CPIndexSet indexSetWithIndex:NaN] }];
|
||||
}
|
||||
|
||||
- (void)testIndexSetWithIndexesInRange
|
||||
|
||||
Reference in new issue
Block a user