@@ -739,6 +739,7 @@ typedef FcFontSet* (*FcFontSortFuncType)(FcConfig *config,
739739 FcResult * result );
740740typedef FcCharSet * (* FcCharSetUnionFuncType )(const FcCharSet * a ,
741741 const FcCharSet * b );
742+ typedef FcCharSet * (* FcCharSetDestroyFuncType )(FcCharSet * fcs );
742743typedef FcChar32 (* FcCharSetSubtractCountFuncType )(const FcCharSet * a ,
743744 const FcCharSet * b );
744745
@@ -1024,6 +1025,7 @@ Java_sun_font_FontConfigManager_getFontConfig
10241025 FcFontSortFuncType FcFontSort ;
10251026 FcFontSetDestroyFuncType FcFontSetDestroy ;
10261027 FcCharSetUnionFuncType FcCharSetUnion ;
1028+ FcCharSetDestroyFuncType FcCharSetDestroy ;
10271029 FcCharSetSubtractCountFuncType FcCharSetSubtractCount ;
10281030 FcGetVersionFuncType FcGetVersion ;
10291031 FcConfigGetCacheDirsFuncType FcConfigGetCacheDirs ;
@@ -1103,6 +1105,8 @@ Java_sun_font_FontConfigManager_getFontConfig
11031105 (FcFontSetDestroyFuncType )dlsym (libfontconfig , "FcFontSetDestroy" );
11041106 FcCharSetUnion =
11051107 (FcCharSetUnionFuncType )dlsym (libfontconfig , "FcCharSetUnion" );
1108+ FcCharSetDestroy =
1109+ (FcCharSetDestroyFuncType )dlsym (libfontconfig , "FcCharSetDestroy" );
11061110 FcCharSetSubtractCount =
11071111 (FcCharSetSubtractCountFuncType )dlsym (libfontconfig ,
11081112 "FcCharSetSubtractCount" );
@@ -1118,6 +1122,7 @@ Java_sun_font_FontConfigManager_getFontConfig
11181122 FcPatternGetCharSet == NULL ||
11191123 FcFontSetDestroy == NULL ||
11201124 FcCharSetUnion == NULL ||
1125+ FcCharSetDestroy == NULL ||
11211126 FcGetVersion == NULL ||
11221127 FcCharSetSubtractCount == NULL ) {/* problem with the library: return.*/
11231128 closeFontConfig (libfontconfig , JNI_FALSE );
@@ -1181,6 +1186,7 @@ Java_sun_font_FontConfigManager_getFontConfig
11811186 FcChar8 * * family , * * styleStr , * * fullname , * * file ;
11821187 jarray fcFontArr = NULL ;
11831188 FcCharSet * unionCharset = NULL ;
1189+ FcCharSet * prevUnionCharset = NULL ;
11841190
11851191 fcCompFontObj = (* env )-> GetObjectArrayElement (env , fcCompFontArray , i );
11861192 fcNameStr =
@@ -1294,6 +1300,9 @@ Java_sun_font_FontConfigManager_getFontConfig
12941300 free (file );
12951301 (* FcPatternDestroy )(pattern );
12961302 (* FcFontSetDestroy )(fontset );
1303+ if (prevUnionCharset != NULL ) {
1304+ (* FcCharSetDestroy )(prevUnionCharset );
1305+ }
12971306 closeFontConfig (libfontconfig , JNI_FALSE );
12981307 if (locale ) {
12991308 (* env )-> ReleaseStringUTFChars (env , localeStr , (const char * )locale );
@@ -1315,6 +1324,10 @@ Java_sun_font_FontConfigManager_getFontConfig
13151324 if ((* FcCharSetSubtractCount )(charset , unionCharset )
13161325 > minGlyphs ) {
13171326 unionCharset = (* FcCharSetUnion )(unionCharset , charset );
1327+ if (prevUnionCharset != NULL ) {
1328+ (* FcCharSetDestroy )(prevUnionCharset );
1329+ }
1330+ prevUnionCharset = unionCharset ;
13181331 } else {
13191332 continue ;
13201333 }
@@ -1333,6 +1346,11 @@ Java_sun_font_FontConfigManager_getFontConfig
13331346 }
13341347 }
13351348
1349+ // Release last instance of CharSet union
1350+ if (prevUnionCharset != NULL ) {
1351+ (* FcCharSetDestroy )(prevUnionCharset );
1352+ }
1353+
13361354 /* Once we get here 'fontCount' is the number of returned fonts
13371355 * we actually want to use, so we create 'fcFontArr' of that length.
13381356 * The non-null entries of "family[]" etc are those fonts.
0 commit comments