Skip to content

Commit bb67ea6

Browse files
Adapt 8361959: [GCC static analyzer] java_props_md.c leak of 'temp' variable is reported.
1 parent 4db96bc commit bb67ea6

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/locale/LocaleCHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class LocaleCHelper {
5959
* {@link #SVM_LOCALE_INITIALIZATION_OUT_OF_MEMORY}.
6060
*/
6161
@CFunction(value = "svm_initialize_locale", transition = NO_TRANSITION)
62-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-24+17/src/java.base/unix/native/libjava/java_props_md.c#L71-L357")
62+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+7/src/java.base/unix/native/libjava/java_props_md.c#L71-L359")
6363
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-24+17/src/java.base/unix/native/libjava/java_props_md.c#L436-L460")
6464
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+21/src/java.base/windows/native/libjava/java_props_md.c#L263-L721")
6565
static native int initializeLocale();

substratevm/src/com.oracle.svm.native.libchelper/src/locale.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ static int ParseLocale(int cat, char ** std_language, char ** std_script,
206206
if (language != NULL && mapLookup(language_names, language, std_language) == 0) {
207207
*std_language = malloc(strlen(language)+1);
208208
if (*std_language == NULL) {
209+
free(temp);
209210
free(encoding_variant);
210211
return SVM_LOCALE_INITIALIZATION_OUT_OF_MEMORY;
211212
}
@@ -218,6 +219,7 @@ static int ParseLocale(int cat, char ** std_language, char ** std_script,
218219
if (mapLookup(country_names, country, std_country) == 0) {
219220
*std_country = malloc(strlen(country)+1);
220221
if (*std_country == NULL) {
222+
free(temp);
221223
free(encoding_variant);
222224
return SVM_LOCALE_INITIALIZATION_OUT_OF_MEMORY;
223225
}

0 commit comments

Comments
 (0)