Skip to content

Commit

Permalink
Issue #135: Fixes bug that causes app to crash while trying to parse …
Browse files Browse the repository at this point in the history
…JSON using invalid encoding
  • Loading branch information
mmattozzi committed Nov 30, 2017
1 parent cae8557 commit 874e5e0
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions core/MainWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -652,9 +652,15 @@ - (void)prettyPrintJsonResponseFromString:(NSData*)jsonData {
};

id parser = [SBJson4Parser parserWithBlock:block allowMultiRoot:NO unwrapRootArray:NO errorHandler:eh];
SBJson4ParserStatus parseStatus = [parser parse:jsonData];
if (parseStatus == SBJson4ParserWaitingForData) {
NSLog(@"Unexpected end of JSON content");
@try {
SBJson4ParserStatus parseStatus = [parser parse:jsonData];
if (parseStatus == SBJson4ParserWaitingForData) {
NSLog(@"Unexpected end of JSON content");
[self printResponsePlain];
}
}
@catch (NSException *exception) {
NSLog(@"Unexpected error parsing JSON content");
[self printResponsePlain];
}
}
Expand Down

0 comments on commit 874e5e0

Please sign in to comment.