< 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 **** /* ! * Copyright (c) 1998, 2018, 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 --- 1,7 ---- /* ! * 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,897 **** return -1; } locale = (*env)->GetStringUTFChars(env, localeStr, 0); if ((libfontconfig = openFontConfig()) == NULL) { ! (*env)->ReleaseStringUTFChars (env, fcNameStr, (const char*)fcName); if (locale) { ! (*env)->ReleaseStringUTFChars (env, localeStr,(const char*)locale); } return -1; } FcNameParse = (FcNameParseFuncType)dlsym(libfontconfig, "FcNameParse"); --- 885,897 ---- return -1; } locale = (*env)->GetStringUTFChars(env, localeStr, 0); if ((libfontconfig = openFontConfig()) == NULL) { ! (*env)->ReleaseStringUTFChars(env, fcNameStr, (const char*)fcName); if (locale) { ! (*env)->ReleaseStringUTFChars(env, localeStr,(const char*)locale); } return -1; } FcNameParse = (FcNameParseFuncType)dlsym(libfontconfig, "FcNameParse");
*** 916,928 **** FcFontMatch == NULL || FcPatternGetBool == NULL || FcPatternGetInteger == NULL || FcPatternDestroy == NULL) { /* problem with the library: return. */ ! (*env)->ReleaseStringUTFChars (env, fcNameStr, (const char*)fcName); if (locale) { ! (*env)->ReleaseStringUTFChars (env, localeStr,(const char*)locale); } closeFontConfig(libfontconfig, JNI_FALSE); return -1; } --- 916,928 ---- FcFontMatch == NULL || FcPatternGetBool == NULL || FcPatternGetInteger == NULL || FcPatternDestroy == NULL) { /* problem with the library: return. */ ! (*env)->ReleaseStringUTFChars(env, fcNameStr, (const char*)fcName); if (locale) { ! (*env)->ReleaseStringUTFChars(env, localeStr,(const char*)locale); } closeFontConfig(libfontconfig, JNI_FALSE); return -1; }
*** 943,955 **** (*FcPatternGetInteger)(matchPattern, FC_RGBA, 0, &rgba); (*FcPatternDestroy)(matchPattern); } (*FcPatternDestroy)(pattern); ! (*env)->ReleaseStringUTFChars (env, fcNameStr, (const char*)fcName); if (locale) { ! (*env)->ReleaseStringUTFChars (env, localeStr, (const char*)locale); } closeFontConfig(libfontconfig, JNI_TRUE); if (antialias == FcFalse) { return TEXT_AA_OFF; --- 943,955 ---- (*FcPatternGetInteger)(matchPattern, FC_RGBA, 0, &rgba); (*FcPatternDestroy)(matchPattern); } (*FcPatternDestroy)(pattern); ! (*env)->ReleaseStringUTFChars(env, fcNameStr, (const char*)fcName); if (locale) { ! (*env)->ReleaseStringUTFChars(env, localeStr, (const char*)locale); } closeFontConfig(libfontconfig, JNI_TRUE); if (antialias == FcFalse) { return TEXT_AA_OFF;
*** 1177,1186 **** --- 1177,1189 ---- 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,1203 **** --- 1197,1209 ---- (*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,1234 **** --- 1231,1243 ---- 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,1276 **** --- 1276,1288 ---- 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,1330 **** --- 1333,1345 ---- 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,1390 **** } /* release resources and close the ".so" */ if (locale) { ! (*env)->ReleaseStringUTFChars (env, localeStr, (const char*)locale); } closeFontConfig(libfontconfig, JNI_TRUE); } --- 1397,1405 ---- } /* release resources and close the ".so" */ if (locale) { ! (*env)->ReleaseStringUTFChars(env, localeStr, (const char*)locale); } closeFontConfig(libfontconfig, JNI_TRUE); }
< prev index next >