Skip to content

Commit 1285ef7

Browse files
authored
Merge pull request #3161 from millenomi/cflocale-leak
Solve a memory leak in CFLocaleGetSystem()
2 parents 12525c2 + 1393eaf commit 1285ef7

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)