mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Fix potential crash if json string is nil
This commit is contained in:
parent
d4c7273946
commit
0dc8ed1a34
@ -634,6 +634,9 @@ static NSString *kHockeyErrorDomain = @"HockeyErrorDomain";
|
|||||||
NSError *error = nil;
|
NSError *error = nil;
|
||||||
id feedResult = nil;
|
id feedResult = nil;
|
||||||
|
|
||||||
|
if (!jsonString)
|
||||||
|
return nil;
|
||||||
|
|
||||||
#if BW_NATIVE_JSON_AVAILABLE
|
#if BW_NATIVE_JSON_AVAILABLE
|
||||||
feedResult = [NSJSONSerialization JSONObjectWithData:[jsonString dataUsingEncoding:NSUTF8StringEncoding] options:kNilOptions error:&error];
|
feedResult = [NSJSONSerialization JSONObjectWithData:[jsonString dataUsingEncoding:NSUTF8StringEncoding] options:kNilOptions error:&error];
|
||||||
#else
|
#else
|
||||||
@ -648,6 +651,10 @@ static NSString *kHockeyErrorDomain = @"HockeyErrorDomain";
|
|||||||
invocation.target = nsjsonClass;
|
invocation.target = nsjsonClass;
|
||||||
invocation.selector = nsjsonSelect;
|
invocation.selector = nsjsonSelect;
|
||||||
NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
|
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
|
[invocation setArgument:&jsonData atIndex:2]; // arguments 0 and 1 are self and _cmd respectively, automatically set by NSInvocation
|
||||||
NSUInteger readOptions = kNilOptions;
|
NSUInteger readOptions = kNilOptions;
|
||||||
[invocation setArgument:&readOptions atIndex:3];
|
[invocation setArgument:&readOptions atIndex:3];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user