You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2014/09/15 01:59:50 UTC
ios commit: CB-7546 - [Contacts][iOS] Prevent exception when index is
out of range
Repository: cordova-ios
Updated Branches:
refs/heads/master 38e05366a -> efde32e4b
CB-7546 - [Contacts][iOS] Prevent exception when index is out of range
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/efde32e4
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/efde32e4
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/efde32e4
Branch: refs/heads/master
Commit: efde32e4baa5ac00992c1ce248ba18cb2de8ce2e
Parents: 38e0536
Author: Shazron Abdullah <sh...@apache.org>
Authored: Sun Sep 14 16:58:53 2014 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Sun Sep 14 16:59:42 2014 -0700
----------------------------------------------------------------------
CordovaLib/Classes/NSArray+Comparisons.m | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/efde32e4/CordovaLib/Classes/NSArray+Comparisons.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/NSArray+Comparisons.m b/CordovaLib/Classes/NSArray+Comparisons.m
index 485e3c8..e29c03d 100644
--- a/CordovaLib/Classes/NSArray+Comparisons.m
+++ b/CordovaLib/Classes/NSArray+Comparisons.m
@@ -24,9 +24,11 @@
- (id)objectAtIndex:(NSUInteger)index withDefault:(id)aDefault
{
id obj = nil;
-
+
@try {
- obj = [self objectAtIndex:index];
+ if (index < [self count]) {
+ obj = [self objectAtIndex:index];
+ }
if ((obj == [NSNull null]) || (obj == nil)) {
return aDefault;
}
@@ -34,7 +36,7 @@
@catch(NSException* exception) {
NSLog(@"Exception - Name: %@ Reason: %@", [exception name], [exception reason]);
}
-
+
return obj;
}