Fix potential crash if json string is nil

This commit is contained in:
Andreas Linde 2012-02-10 19:40:30 +01:00
parent d4c7273946
commit 0dc8ed1a34

View File

@ -634,6 +634,9 @@ static NSString *kHockeyErrorDomain = @"HockeyErrorDomain";
NSError *error = nil;
id feedResult = nil;
if (!jsonString)
return nil;
#if BW_NATIVE_JSON_AVAILABLE
feedResult = [NSJSONSerialization JSONObjectWithData:[jsonString dataUsingEncoding:NSUTF8StringEncoding] options:kNilOptions error:&error];
#else
@ -648,6 +651,10 @@ static NSString *kHockeyErrorDomain = @"HockeyErrorDomain";
invocation.target = nsjsonClass;
invocation.selector = nsjsonSelect;
NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
if (!jsonData)
return nil;
[invocation setArgument:&jsonData atIndex:2]; // arguments 0 and 1 are self and _cmd respectively, automatically set by NSInvocation
NSUInteger readOptions = kNilOptions;
[invocation setArgument:&readOptions atIndex:3];