8031095: [Parfait] warning from jdk/src/solaris/native/sun/awt: memory leak
authorprr
Fri, 04 Apr 2014 11:18:28 -0700
changeset 24162 0fe6fb6759ab
parent 24161 29dc629ec823
child 24163 d56df89854c4
8031095: [Parfait] warning from jdk/src/solaris/native/sun/awt: memory leak Reviewed-by: bae, jgodinez
jdk/src/solaris/native/sun/awt/awt_Font.c
--- a/jdk/src/solaris/native/sun/awt/awt_Font.c	Fri Apr 04 10:24:11 2014 -0700
+++ b/jdk/src/solaris/native/sun/awt/awt_Font.c	Fri Apr 04 11:18:28 2014 -0700
@@ -555,6 +555,19 @@
                     fdata->xfont = fdata->flist[i].xfont;
                     fdata->flist[i].index_length = 1;
                 } else {
+                    /* Free any already allocated storage and fonts */
+                    int j = i;
+                    for (j = 0; j <= i; j++) {
+                        free((void *)fdata->flist[j].xlfd);
+                        JNU_ReleaseStringPlatformChars(env, NULL,
+                            fdata->flist[j].charset_name);
+                        if (fdata->flist[j].load) {
+                            XFreeFont(awt_display, fdata->flist[j].xfont);
+                        }
+                    }
+                    free((void *)fdata->flist);
+                    free((void *)fdata);
+
                     if (errmsg != NULL) {
                         *errmsg = "java/lang" "NullPointerException";
                     }