Skip to content

[5.2] SR-11917: Using JSONEncoder's .outputFormatting = .sortedKeys has a memory leak on Linux #2692

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 1, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions CoreFoundation/String.subproj/CFStringUtilities.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ static UCollator *__CFStringCopyDefaultCollator(CFLocaleRef compareLocale) {
return collator;
}

#if TARGET_OS_MAC
#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX
static void __collatorFinalize(UCollator *collator) {
CFLocaleRef locale = _CFGetTSD(__CFTSDKeyCollatorLocale);
_CFSetTSD(__CFTSDKeyCollatorUCollator, NULL, NULL);
Expand Down Expand Up @@ -603,28 +603,24 @@ CF_PRIVATE CFComparisonResult _CFCompareStringsWithLocale(CFStringInlineBuffer *
if (range2.location > 0) {
range2.location = __extendLocationBackward(range2.location - 1, str2, nonBaseBMP, punctBMP);
}

#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX
#if TARGET_OS_MAC
// First we try to use the last one used on this thread, if the locale is the same,
// otherwise we try to check out a default one, or then we create one.
UCollator *threadCollator = _CFGetTSD(__CFTSDKeyCollatorUCollator);
CFLocaleRef threadLocale = _CFGetTSD(__CFTSDKeyCollatorLocale);
if (compareLocale == threadLocale) {
collator = threadCollator;
} else {
#endif
collator = __CFStringCopyDefaultCollator((CFLocaleRef)compareLocale);
defaultCollator = true;
if (NULL == collator) {
collator = __CFStringCreateCollator((CFLocaleRef)compareLocale);
defaultCollator = false;
}
#if TARGET_OS_MAC
}
#endif
#endif


characters1 = CFStringGetCharactersPtrFromInlineBuffer(str1, range1);
characters2 = CFStringGetCharactersPtrFromInlineBuffer(str2, range2);

Expand Down Expand Up @@ -739,7 +735,7 @@ CF_PRIVATE CFComparisonResult _CFCompareStringsWithLocale(CFStringInlineBuffer *
if (buffer2Len > 0) CFAllocatorDeallocate(kCFAllocatorSystemDefault, buffer2);
}

#if TARGET_OS_MAC
#if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX
if (collator == threadCollator) {
// do nothing, already cached
} else {
Expand Down