A framework is used in iOS application. In framework network change status is observed and callback code segment is something like this:
NSString *initialAPName = nil;
NSString* getSSID() {
__block NSString *ssid = nil;
dispatch_semaphore_t sem = dispatch_semaphore_create(0);
[NEHotspotNetwork fetchCurrentWithCompletionHandler:^(NEHotspotNetwork * _Nullable currentNetwork) {
if( currentNetwork != nil) {
ssid = [currentNetwork SSID];
}
dispatch_semaphore_signal(sem);
}];
dispatch_time_t timeout = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC));
dispatch_semaphore_wait(sem, timeout);
return ssid;
}
static void onNotifyCallback(CFNotificationCenterRef center, void *observer, CFStringRef name,
const void *object, CFDictionaryRef userInfo)
{
NSString *apName = getSSID();
if([apName isEqualToString:initialAPName]) { //Crashes here
initialAPName = apName;
}
}
Using of [NSString UTF8String] also crashes.
The crash occurs only when apName contains special characters like (_, -, ') and it only occurs in iOS 15.5 or later.