8228501: java_props_macosx.c - provide missing CFRelease for CFLocaleCopyCurrent

Reviewed-by: naoto
This commit is contained in:
Matthias Baesken 2019-07-24 09:28:48 +02:00
parent 6a94be7047
commit ff6b5404eb

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -91,7 +91,9 @@ char *getMacOSXLocale(int cat) {
if (hyphenPos == NULL || // languageString contains ISO639 only, e.g., "en"
languageString + langStrLen - hyphenPos == 5) { // ISO639-ScriptCode, e.g., "en-Latn"
CFStringGetCString(CFLocaleGetIdentifier(CFLocaleCopyCurrent()),
CFLocaleRef cflocale = CFLocaleCopyCurrent();
if (cflocale != NULL) {
CFStringGetCString(CFLocaleGetIdentifier(cflocale),
localeString, LOCALEIDLENGTH, CFStringGetSystemEncoding());
char *underscorePos = strrchr(localeString, '_');
char *region = NULL;
@ -104,6 +106,8 @@ char *getMacOSXLocale(int cat) {
strcat(languageString, "-");
strcat(languageString, region);
}
CFRelease(cflocale);
}
}
retVal = languageString;
@ -112,12 +116,19 @@ char *getMacOSXLocale(int cat) {
default:
{
if (!CFStringGetCString(CFLocaleGetIdentifier(CFLocaleCopyCurrent()),
CFLocaleRef cflocale = CFLocaleCopyCurrent();
if (cflocale != NULL) {
if (!CFStringGetCString(CFLocaleGetIdentifier(cflocale),
localeString, LOCALEIDLENGTH, CFStringGetSystemEncoding())) {
CFRelease(cflocale);
return NULL;
}
retVal = localeString;
CFRelease(cflocale);
} else {
return NULL;
}
}
break;
}