Skip to content

Commit 8bcd59c

Browse files
committed
stub for objc_retainAutoreleasedReturnValue should call swift_retain
non cf types can sneak in here so generally CFRetain cannot be called but swift_retain covers both CF cases and non CF cases
1 parent c38806b commit 8bcd59c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

CoreFoundation/Base.subproj/CFRuntime.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1813,8 +1813,11 @@ const char *_NSPrintForDebugger(void *cf) {
18131813
#if DEPLOYMENT_RUNTIME_SWIFT
18141814

18151815
// For CF functions with 'Get' semantics, the compiler currently assumes that the result is autoreleased and must be retained. It does so on all platforms by emitting a call to objc_retainAutoreleasedReturnValue. On Darwin, this is implemented by the ObjC runtime. On Linux, there is no runtime, and therefore we have to stub it out here ourselves. The compiler will eventually call swift_release to balance the retain below. This is a workaround until the compiler no longer emits this callout on Linux.
1816-
CFTypeRef objc_retainAutoreleasedReturnValue(CFTypeRef cf) {
1817-
if (cf) return CFRetain(cf);
1816+
void * objc_retainAutoreleasedReturnValue(void *obj) {
1817+
if (obj) {
1818+
swift_retain(obj);
1819+
return obj;
1820+
}
18181821
else return NULL;
18191822
}
18201823

0 commit comments

Comments
 (0)