Fix crash on iOS when ledger asks for a favicon with an invalid URL

This commit is contained in:
Kyle Hickinson
2020-11-06 14:46:41 -05:00
parent f9d15be7d9
commit 18d1c35264
+5 -3
View File
@@ -1680,11 +1680,13 @@ BATLedgerBridge(BOOL,
- (void)fetchFavIcon:(const std::string &)url faviconKey:(const std::string &)favicon_key callback:(ledger::client::FetchIconCallback)callback
{
if (!self.faviconFetcher) {
callback(NO, std::string());
const auto pageURL = [NSURL URLWithString:[NSString stringWithUTF8String:url.c_str()]];
if (!self.faviconFetcher || !pageURL) {
dispatch_async(dispatch_get_main_queue(), ^{
callback(NO, std::string());
});
return;
}
const auto pageURL = [NSURL URLWithString:[NSString stringWithUTF8String:url.c_str()]];
self.faviconFetcher(pageURL, ^(NSURL * _Nullable faviconURL) {
dispatch_async(dispatch_get_main_queue(), ^{
callback(faviconURL != nil,