Skip to content

Commit dd7e8f7

Browse files
Check string for nil value
make sure to check the string for nil value before doing the caseInsensitiveCompare, otherwise this could introduce a bug.
1 parent 5d1cc85 commit dd7e8f7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

JSONModel/JSONModelTransformations/JSONValueTransformer.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,9 @@ -(NSNumber*)BOOLFromNSNumber:(NSNumber*)number
142142

143143
-(NSNumber*)BOOLFromNSString:(NSString*)string
144144
{
145-
if ([string caseInsensitiveCompare:@"true"] == NSOrderedSame ||
146-
[string caseInsensitiveCompare:@"yes"] == NSOrderedSame) {
145+
if (string != nil &&
146+
([string caseInsensitiveCompare:@"true"] == NSOrderedSame ||
147+
[string caseInsensitiveCompare:@"yes"] == NSOrderedSame)) {
147148
return [NSNumber numberWithBool:YES];
148149
}
149150
int val = [string intValue];

0 commit comments

Comments
 (0)