Skip to content

Commit 1393eaf

Browse files
committed
Solve a memory leak in CFLocaleGetSystem()
These objects have a real (live) retain count rather than being immortal on Swift; do not overretain as it is not a no-op. rdar://88461050
1 parent d956aff commit 1393eaf

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

CoreFoundation/Locale.subproj/CFLocale.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,12 @@ CFLocaleRef CFLocaleGetSystem(void) {
293293
uselessLocale = locale;
294294
}
295295
}
296+
#if !DEPLOYMENT_RUNTIME_SWIFT
297+
// This line relies on the fact that outside of Swift, __CFLocaleSystem is immortal.
296298
locale = __CFLocaleSystem ? (CFLocaleRef)CFRetain(__CFLocaleSystem) : NULL;
299+
#else
300+
locale = __CFLocaleSystem;
301+
#endif
297302
__CFLocaleUnlockGlobal();
298303
if (uselessLocale) CFRelease(uselessLocale);
299304
return locale;

0 commit comments

Comments
 (0)