Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8283217: Leak FcObjectSet in getFontConfigLocations() in fontpath.c
Backport-of: 909986c7e110c8ac3ba16750be7707b1ec344ee5
  • Loading branch information
zhengyu123 committed Apr 10, 2022
1 parent b9a4153 commit 2da50ce
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 @@ -712,6 +712,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 @@ -758,6 +759,7 @@ static char **getFontConfigLocations() {
FcPatternGetStringFuncType FcPatternGetString;
FcStrDirnameFuncType FcStrDirname;
FcPatternDestroyFuncType FcPatternDestroy;
FcObjectSetDestroyFuncType FcObjectSetDestroy;
FcFontSetDestroyFuncType FcFontSetDestroy;

FcConfig *fontconfig;
Expand Down Expand Up @@ -787,6 +789,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 @@ -796,6 +800,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 @@ -852,6 +857,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 2da50ce

@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.