Crash on CFRelease(res)
, below is the codes, please help how to fix it. {
dispatch_block_t block = ^{
//All this dancing is an attempt to work around some weird crash:
//seems like ARC is trying to release NULL before assigning new value
CFDictionaryRef res = SCDynamicStoreCopyMultiple(store, NULL, keyPatterns);
if (res && store) {
NSDictionary *nsRes = (__bridge_transfer NSDictionary *)CFPropertyListCreateDeepCopy(kCFAllocatorDefault,
(CFPropertyListRef)res,
kCFPropertyListImmutable);
setDynamicStore(nsRes);
} else {
ZLogError("SCU:[%s]%s refreshDynamicStore failed",
dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL),
__FUNCTION__);
setDynamicStore(NULL);
}
if(res) {
CFRelease(res);
}
};
if (dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL) == dispatch_queue_get_label(queue)) {
block();
} else {
dispatch_async(queue, block);
}
}