Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8283217: Leak FcObjectSet in getFontConfigLocations() in fontpath.c
Reviewed-by: prr, aivanov
  • Loading branch information
zhengyu123 committed Mar 21, 2022
1 parent b617f1d commit 909986c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/java.desktop/unix/native/common/awt/fontpath.c
Expand Up @@ -496,6 +496,7 @@ typedef FcResult (*FcPatternGetStringFuncType)(const FcPattern *p,
FcChar8 ** s);
typedef FcChar8* (*FcStrDirnameFuncType)(const FcChar8 *file);
typedef void (*FcPatternDestroyFuncType)(FcPattern *p);
typedef void (*FcObjectSetDestroyFuncType)(FcObjectSet *os);
typedef void (*FcFontSetDestroyFuncType)(FcFontSet *s);
typedef FcPattern* (*FcNameParseFuncType)(const FcChar8 *name);
typedef FcBool (*FcPatternAddStringFuncType)(FcPattern *p,
Expand Down Expand Up @@ -542,6 +543,7 @@ static char **getFontConfigLocations() {
FcPatternGetStringFuncType FcPatternGetString;
FcStrDirnameFuncType FcStrDirname;
FcPatternDestroyFuncType FcPatternDestroy;
FcObjectSetDestroyFuncType FcObjectSetDestroy;
FcFontSetDestroyFuncType FcFontSetDestroy;

FcConfig *fontconfig;
Expand Down Expand Up @@ -571,6 +573,8 @@ static char **getFontConfigLocations() {
(FcStrDirnameFuncType)dlsym(libfontconfig, "FcStrDirname");
FcPatternDestroy =
(FcPatternDestroyFuncType)dlsym(libfontconfig, "FcPatternDestroy");
FcObjectSetDestroy =
(FcObjectSetDestroyFuncType)dlsym(libfontconfig, "FcObjectSetDestroy");
FcFontSetDestroy =
(FcFontSetDestroyFuncType)dlsym(libfontconfig, "FcFontSetDestroy");

Expand All @@ -580,6 +584,7 @@ static char **getFontConfigLocations() {
FcFontList == NULL ||
FcStrDirname == NULL ||
FcPatternDestroy == NULL ||
FcObjectSetDestroy == NULL ||
FcFontSetDestroy == NULL) { /* problem with the library: return. */
closeFontConfig(libfontconfig, JNI_FALSE);
return NULL;
Expand Down Expand Up @@ -636,6 +641,7 @@ static char **getFontConfigLocations() {

cleanup:
/* Free memory and close the ".so" */
(*FcObjectSetDestroy)(objset);
(*FcPatternDestroy)(pattern);
closeFontConfig(libfontconfig, JNI_TRUE);
return fontdirs;
Expand Down

1 comment on commit 909986c

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.