< prev index next >
src/java.desktop/unix/native/common/awt/fontpath.c
Print this page
rev 56251 : 8230900: missing ReleaseStringUTFChars in java.desktop native code
@@ -1,7 +1,7 @@
/*
- * 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -885,13 +885,13 @@
return -1;
}
locale = (*env)->GetStringUTFChars(env, localeStr, 0);
if ((libfontconfig = openFontConfig()) == NULL) {
- (*env)->ReleaseStringUTFChars (env, fcNameStr, (const char*)fcName);
+ (*env)->ReleaseStringUTFChars(env, fcNameStr, (const char*)fcName);
if (locale) {
- (*env)->ReleaseStringUTFChars (env, localeStr,(const char*)locale);
+ (*env)->ReleaseStringUTFChars(env, localeStr,(const char*)locale);
}
return -1;
}
FcNameParse = (FcNameParseFuncType)dlsym(libfontconfig, "FcNameParse");
@@ -916,13 +916,13 @@
FcFontMatch == NULL ||
FcPatternGetBool == NULL ||
FcPatternGetInteger == NULL ||
FcPatternDestroy == NULL) { /* problem with the library: return. */
- (*env)->ReleaseStringUTFChars (env, fcNameStr, (const char*)fcName);
+ (*env)->ReleaseStringUTFChars(env, fcNameStr, (const char*)fcName);
if (locale) {
- (*env)->ReleaseStringUTFChars (env, localeStr,(const char*)locale);
+ (*env)->ReleaseStringUTFChars(env, localeStr,(const char*)locale);
}
closeFontConfig(libfontconfig, JNI_FALSE);
return -1;
}
@@ -943,13 +943,13 @@
(*FcPatternGetInteger)(matchPattern, FC_RGBA, 0, &rgba);
(*FcPatternDestroy)(matchPattern);
}
(*FcPatternDestroy)(pattern);
- (*env)->ReleaseStringUTFChars (env, fcNameStr, (const char*)fcName);
+ (*env)->ReleaseStringUTFChars(env, fcNameStr, (const char*)fcName);
if (locale) {
- (*env)->ReleaseStringUTFChars (env, localeStr, (const char*)locale);
+ (*env)->ReleaseStringUTFChars(env, localeStr, (const char*)locale);
}
closeFontConfig(libfontconfig, JNI_TRUE);
if (antialias == FcFalse) {
return TEXT_AA_OFF;
@@ -1177,10 +1177,13 @@
pattern = (*FcNameParse)((FcChar8 *)fcName);
(*env)->ReleaseStringUTFChars(env, fcNameStr, (const char*)fcName);
(*env)->DeleteLocalRef(env, fcNameStr);
if (pattern == NULL) {
closeFontConfig(libfontconfig, JNI_FALSE);
+ if (locale) {
+ (*env)->ReleaseStringUTFChars(env, localeStr, (const char*)locale);
+ }
return;
}
/* locale may not usually be necessary as fontconfig appears to apply
* this anyway based on the user's environment. However we want
@@ -1194,10 +1197,13 @@
(*FcDefaultSubstitute)(pattern);
fontset = (*FcFontSort)(NULL, pattern, FcTrue, NULL, &result);
if (fontset == NULL) {
(*FcPatternDestroy)(pattern);
closeFontConfig(libfontconfig, JNI_FALSE);
+ if (locale) {
+ (*env)->ReleaseStringUTFChars(env, localeStr, (const char*)locale);
+ }
return;
}
/* fontconfig returned us "nfonts". If we are just getting the
* first font, we set nfont to zero. Otherwise we use "nfonts".
@@ -1225,10 +1231,13 @@
free(file);
}
(*FcPatternDestroy)(pattern);
(*FcFontSetDestroy)(fontset);
closeFontConfig(libfontconfig, JNI_FALSE);
+ if (locale) {
+ (*env)->ReleaseStringUTFChars(env, localeStr, (const char*)locale);
+ }
return;
}
fontCount = 0;
minGlyphs = 20;
if (debugMinGlyphsStr != NULL) {
@@ -1267,10 +1276,13 @@
free(styleStr);
free(file);
(*FcPatternDestroy)(pattern);
(*FcFontSetDestroy)(fontset);
closeFontConfig(libfontconfig, JNI_FALSE);
+ if (locale) {
+ (*env)->ReleaseStringUTFChars(env, localeStr, (const char*)locale);
+ }
return;
}
/* We don't want 20 or 30 fonts, so once we hit 10 fonts,
* then require that they really be adding value. Too many
@@ -1321,10 +1333,13 @@
free(styleStr);
free(file);
(*FcPatternDestroy)(pattern);
(*FcFontSetDestroy)(fontset);
closeFontConfig(libfontconfig, JNI_FALSE);
+ if (locale) {
+ (*env)->ReleaseStringUTFChars(env, localeStr, (const char*)locale);
+ }
return;
}
(*env)->SetObjectField(env,fcCompFontObj, fcAllFontsID, fcFontArr);
}
fn=0;
@@ -1382,9 +1397,9 @@
}
/* release resources and close the ".so" */
if (locale) {
- (*env)->ReleaseStringUTFChars (env, localeStr, (const char*)locale);
+ (*env)->ReleaseStringUTFChars(env, localeStr, (const char*)locale);
}
closeFontConfig(libfontconfig, JNI_TRUE);
}
< prev index next >