Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8282628

Potential memory leak in sun.font.FontConfigManager.getFontConfig()

    XMLWordPrintable

Details

    • 2d
    • b13

    Backports

      Description

        The method is a native method defined in fontpath.c

        Java_sun_font_FontConfigManager_getFontConfig {

        ...
         cacheDirs = (*FcConfigGetCacheDirs)(NULL);
            935 if (cacheDirs != NULL) {
            936 while ((cnt < max) && (cacheDir = (*FcStrListNext)(cacheDirs))) {
            937 jstr = (*env)->NewStringUTF(env, (const char*)cacheDir);
            938 JNU_CHECK_EXCEPTION(env);
            939
            940 (*env)->SetObjectArrayElement(env, cacheDirArray, cnt++, jstr);
            941 (*env)->DeleteLocalRef(env, jstr);
            942 }
            943 (*FcStrListDone)(cacheDirs);
            944 }

        ...
        }

        cacheDir is allocated by (*FcConfigGetCacheDirs)(NULL), but inside the while loop, if there is an exception occurred, macro JNU_CHECK_EXCEPTION(env) [1] ; will return without calling (*FcStrListDone)(cacheDirs);, therefore, cacheDir is leaked.

        [1] #define JNU_CHECK_EXCEPTION(env) \
            do { \
                if ((env)->ExceptionCheck()) { \
                    return; \
                } \
            } while (0) \

        Attachments

          Issue Links

            Activity

              People

                zgu Zhengyu Gu
                zgu Zhengyu Gu
                Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: