jdk/src/share/native/sun/font/freetypeScaler.c
changeset 4243 657b5136de1a
parent 2369 b58cdc0321f5
child 5506 202f599c92aa
child 5579 1a5e995a710b
--- a/jdk/src/share/native/sun/font/freetypeScaler.c	Tue Sep 29 22:49:43 2009 -0700
+++ b/jdk/src/share/native/sun/font/freetypeScaler.c	Fri Oct 02 10:15:12 2009 -0700
@@ -102,9 +102,21 @@
 }
 
 static void freeNativeResources(JNIEnv *env, FTScalerInfo* scalerInfo) {
+    void *stream;
+
     if (scalerInfo == NULL)
         return;
 
+    //apparently Done_Face will only close the stream
+    // but will not relase the memory of stream structure.
+    // We need to free it explicitly to avoid leak.
+    //Direct access to the stream field might be not ideal solution as
+    // it is considred to be "private".
+    //Alternatively we could have stored pointer to the structure
+    // in the scalerInfo but this will increase size of the structure
+    // for no good reason
+    stream = scalerInfo->face->stream;
+
     FT_Done_Face(scalerInfo->face);
     FT_Done_FreeType(scalerInfo->library);
 
@@ -116,6 +128,10 @@
         free(scalerInfo->fontData);
     }
 
+   if (stream != NULL) {
+        free(stream);
+   }
+
     free(scalerInfo);
 }