8143002: [Parfait] JNI exception pending in fontpath.c:1300
Reviewed-by: prr, serb
diff --git a/src/solaris/native/sun/awt/fontpath.c b/src/solaris/native/sun/awt/fontpath.c
index 674931b..3d1d020 100644
--- a/src/solaris/native/sun/awt/fontpath.c
+++ b/src/solaris/native/sun/awt/fontpath.c
@@ -1155,8 +1155,8 @@
continue;
}
pattern = (*FcNameParse)((FcChar8 *)fcName);
+ (*env)->ReleaseStringUTFChars(env, fcNameStr, (const char*)fcName);
if (pattern == NULL) {
- (*env)->ReleaseStringUTFChars(env, fcNameStr, (const char*)fcName);
closeFontConfig(libfontconfig, JNI_FALSE);
return;
}
@@ -1174,7 +1174,6 @@
fontset = (*FcFontSort)(NULL, pattern, FcTrue, NULL, &result);
if (fontset == NULL) {
(*FcPatternDestroy)(pattern);
- (*env)->ReleaseStringUTFChars(env, fcNameStr, (const char*)fcName);
closeFontConfig(libfontconfig, JNI_FALSE);
return;
}
@@ -1206,7 +1205,6 @@
}
(*FcPatternDestroy)(pattern);
(*FcFontSetDestroy)(fontset);
- (*env)->ReleaseStringUTFChars(env, fcNameStr, (const char*)fcName);
closeFontConfig(libfontconfig, JNI_FALSE);
return;
}
@@ -1248,8 +1246,6 @@
free(file);
(*FcPatternDestroy)(pattern);
(*FcFontSetDestroy)(fontset);
- (*env)->ReleaseStringUTFChars(env,
- fcNameStr, (const char*)fcName);
closeFontConfig(libfontconfig, JNI_FALSE);
return;
}
@@ -1297,6 +1293,16 @@
if (includeFallbacks) {
fcFontArr =
(*env)->NewObjectArray(env, fontCount, fcFontClass, NULL);
+ if (IS_NULL(fcFontArr)) {
+ free(family);
+ free(fullname);
+ free(styleStr);
+ free(file);
+ (*FcPatternDestroy)(pattern);
+ (*FcFontSetDestroy)(fontset);
+ closeFontConfig(libfontconfig, JNI_FALSE);
+ return;
+ }
(*env)->SetObjectField(env,fcCompFontObj, fcAllFontsID, fcFontArr);
}
fn=0;
@@ -1305,18 +1311,23 @@
if (family[j] != NULL) {
jobject fcFont =
(*env)->NewObject(env, fcFontClass, fcFontCons);
+ if (IS_NULL(fcFont)) break;
jstr = (*env)->NewStringUTF(env, (const char*)family[j]);
+ if (IS_NULL(jstr)) break;
(*env)->SetObjectField(env, fcFont, familyNameID, jstr);
if (file[j] != NULL) {
jstr = (*env)->NewStringUTF(env, (const char*)file[j]);
+ if (IS_NULL(jstr)) break;
(*env)->SetObjectField(env, fcFont, fontFileID, jstr);
}
if (styleStr[j] != NULL) {
jstr = (*env)->NewStringUTF(env, (const char*)styleStr[j]);
+ if (IS_NULL(jstr)) break;
(*env)->SetObjectField(env, fcFont, styleNameID, jstr);
}
if (fullname[j] != NULL) {
jstr = (*env)->NewStringUTF(env, (const char*)fullname[j]);
+ if (IS_NULL(jstr)) break;
(*env)->SetObjectField(env, fcFont, fullNameID, jstr);
}
if (fn==0) {
@@ -1330,7 +1341,6 @@
}
}
}
- (*env)->ReleaseStringUTFChars (env, fcNameStr, (const char*)fcName);
(*FcFontSetDestroy)(fontset);
(*FcPatternDestroy)(pattern);
free(family);