Skip to content

Commit b0a9107

Browse files
committed
Guard autorelease callouts to not be built for swift runtime builds in CFError
1 parent 59ea44d commit b0a9107

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

CoreFoundation/Error.subproj/CFError.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,13 @@ CFErrorUserInfoKeyCallBackBlock CFErrorGetCallBackBlockForDomain(CFStringRef dom
559559

560560
void CFErrorSetCallBackForDomain(CFStringRef domainName, CFErrorUserInfoKeyCallBack callBack) {
561561
// Since we have replaced the callback functionality with a callback block functionality, we now register (legacy) callback functions embedded in a block which autoreleases the result
562-
CFErrorUserInfoKeyCallBackBlock block = (!callBack) ? NULL : ^(CFErrorRef err, CFStringRef key){CFTypeRef result = callBack(err, key); if (result) CFAutorelease(result); return result;};
562+
CFErrorUserInfoKeyCallBackBlock block = (!callBack) ? NULL : ^(CFErrorRef err, CFStringRef key){
563+
CFTypeRef result = callBack(err, key);
564+
#if !DEPLOYMENT_RUNTIME_SWIFT
565+
if (result) CFAutorelease(result);
566+
#endif
567+
return result;
568+
};
563569
CFErrorSetCallBackBlockForDomain(domainName, block);
564570
}
565571

0 commit comments

Comments
 (0)