@@ -523,6 +523,7 @@ typedef FcFontSet* (*FcFontSortFuncType)(FcConfig *config,
523523 FcResult * result );
524524typedef FcCharSet * (* FcCharSetUnionFuncType )(const FcCharSet * a ,
525525 const FcCharSet * b );
526+ typedef FcCharSet * (* FcCharSetDestroyFuncType )(FcCharSet * fcs );
526527typedef FcChar32 (* FcCharSetSubtractCountFuncType )(const FcCharSet * a ,
527528 const FcCharSet * b );
528529
@@ -808,6 +809,7 @@ Java_sun_font_FontConfigManager_getFontConfig
808809 FcFontSortFuncType FcFontSort ;
809810 FcFontSetDestroyFuncType FcFontSetDestroy ;
810811 FcCharSetUnionFuncType FcCharSetUnion ;
812+ FcCharSetDestroyFuncType FcCharSetDestroy ;
811813 FcCharSetSubtractCountFuncType FcCharSetSubtractCount ;
812814 FcGetVersionFuncType FcGetVersion ;
813815 FcConfigGetCacheDirsFuncType FcConfigGetCacheDirs ;
@@ -887,6 +889,8 @@ Java_sun_font_FontConfigManager_getFontConfig
887889 (FcFontSetDestroyFuncType )dlsym (libfontconfig , "FcFontSetDestroy" );
888890 FcCharSetUnion =
889891 (FcCharSetUnionFuncType )dlsym (libfontconfig , "FcCharSetUnion" );
892+ FcCharSetDestroy =
893+ (FcCharSetDestroyFuncType )dlsym (libfontconfig , "FcCharSetDestroy" );
890894 FcCharSetSubtractCount =
891895 (FcCharSetSubtractCountFuncType )dlsym (libfontconfig ,
892896 "FcCharSetSubtractCount" );
@@ -902,6 +906,7 @@ Java_sun_font_FontConfigManager_getFontConfig
902906 FcPatternGetCharSet == NULL ||
903907 FcFontSetDestroy == NULL ||
904908 FcCharSetUnion == NULL ||
909+ FcCharSetDestroy == NULL ||
905910 FcGetVersion == NULL ||
906911 FcCharSetSubtractCount == NULL ) {/* problem with the library: return.*/
907912 closeFontConfig (libfontconfig , JNI_FALSE );
@@ -967,6 +972,7 @@ Java_sun_font_FontConfigManager_getFontConfig
967972 FcChar8 * * family , * * styleStr , * * fullname , * * file ;
968973 jarray fcFontArr = NULL ;
969974 FcCharSet * unionCharset = NULL ;
975+ FcCharSet * prevUnionCharset = NULL ;
970976
971977 fcCompFontObj = (* env )-> GetObjectArrayElement (env , fcCompFontArray , i );
972978 fcNameStr =
@@ -1080,6 +1086,9 @@ Java_sun_font_FontConfigManager_getFontConfig
10801086 free (file );
10811087 (* FcPatternDestroy )(pattern );
10821088 (* FcFontSetDestroy )(fontset );
1089+ if (prevUnionCharset != NULL ) {
1090+ (* FcCharSetDestroy )(prevUnionCharset );
1091+ }
10831092 closeFontConfig (libfontconfig , JNI_FALSE );
10841093 if (locale ) {
10851094 (* env )-> ReleaseStringUTFChars (env , localeStr , (const char * )locale );
@@ -1101,6 +1110,10 @@ Java_sun_font_FontConfigManager_getFontConfig
11011110 if ((* FcCharSetSubtractCount )(charset , unionCharset )
11021111 > minGlyphs ) {
11031112 unionCharset = (* FcCharSetUnion )(unionCharset , charset );
1113+ if (prevUnionCharset != NULL ) {
1114+ (* FcCharSetDestroy )(prevUnionCharset );
1115+ }
1116+ prevUnionCharset = unionCharset ;
11041117 } else {
11051118 continue ;
11061119 }
@@ -1119,6 +1132,11 @@ Java_sun_font_FontConfigManager_getFontConfig
11191132 }
11201133 }
11211134
1135+ // Release last instance of CharSet union
1136+ if (prevUnionCharset != NULL ) {
1137+ (* FcCharSetDestroy )(prevUnionCharset );
1138+ }
1139+
11221140 /* Once we get here 'fontCount' is the number of returned fonts
11231141 * we actually want to use, so we create 'fcFontArr' of that length.
11241142 * The non-null entries of "family[]" etc are those fonts.
0 commit comments