# HG changeset patch # User prr # Date 1295625555 28800 # Node ID 073e8ab25a02d65464e875b3bcee11121210c5f2 # Parent 6711180a6212a91719344764db9cb95aef8e41e1 6892493: potential memory leaks in 2D font code indentified by parfait. Reviewed-by: bae, igor diff -r 6711180a6212 -r 073e8ab25a02 jdk/src/solaris/native/sun/awt/fontpath.c --- a/jdk/src/solaris/native/sun/awt/fontpath.c Thu Jan 20 13:56:26 2011 -0800 +++ b/jdk/src/solaris/native/sun/awt/fontpath.c Fri Jan 21 07:59:15 2011 -0800 @@ -1120,6 +1120,7 @@ } pattern = (*FcNameParse)((FcChar8 *)fcName); if (pattern == NULL) { + (*env)->ReleaseStringUTFChars(env, fcNameStr, (const char*)fcName); closeFontConfig(libfontconfig, JNI_FALSE); return; } @@ -1136,6 +1137,8 @@ (*FcDefaultSubstitute)(pattern); fontset = (*FcFontSort)(NULL, pattern, FcTrue, NULL, &result); if (fontset == NULL) { + (*FcPatternDestroy)(pattern); + (*env)->ReleaseStringUTFChars(env, fcNameStr, (const char*)fcName); closeFontConfig(libfontconfig, JNI_FALSE); return; } @@ -1153,6 +1156,21 @@ file = (FcChar8**)calloc(nfonts, sizeof(FcChar8*)); if (family == NULL || styleStr == NULL || fullname == NULL || file == NULL) { + if (family != NULL) { + free(family); + } + if (styleStr != NULL) { + free(styleStr); + } + if (fullname != NULL) { + free(fullname); + } + if (file != NULL) { + free(file); + } + (*FcPatternDestroy)(pattern); + (*FcFontSetDestroy)(fontset); + (*env)->ReleaseStringUTFChars(env, fcNameStr, (const char*)fcName); closeFontConfig(libfontconfig, JNI_FALSE); return; } @@ -1179,6 +1197,14 @@ result = (*FcPatternGetCharSet)(fontPattern, FC_CHARSET, 0, &charset); if (result != FcResultMatch) { + free(family); + free(family); + free(styleStr); + free(file); + (*FcPatternDestroy)(pattern); + (*FcFontSetDestroy)(fontset); + (*env)->ReleaseStringUTFChars(env, + fcNameStr, (const char*)fcName); closeFontConfig(libfontconfig, JNI_FALSE); return; }