8025664: [parfait] warnings from b62 for jdk.src.share.native.sun.font
authorjchen
Thu, 03 Oct 2013 13:41:53 -0700
changeset 20424 eace1945b974
parent 20423 23b2db6ffff4
child 20425 5964c0fc5cc0
8025664: [parfait] warnings from b62 for jdk.src.share.native.sun.font Reviewed-by: prr, jgodinez
jdk/src/share/native/sun/font/freetypeScaler.c
--- a/jdk/src/share/native/sun/font/freetypeScaler.c	Thu Oct 03 13:35:26 2013 -0700
+++ b/jdk/src/share/native/sun/font/freetypeScaler.c	Thu Oct 03 13:41:53 2013 -0700
@@ -252,7 +252,6 @@
         JNIEnv *env, jobject scaler, jobject font2D, jint type,
         jint indexInCollection, jboolean supportsCJK, jint filesize) {
     FTScalerInfo* scalerInfo = NULL;
-    FT_Stream ftstream;
     FT_Open_Args ft_open_args;
     int error;
     jobject bBuffer;
@@ -309,34 +308,36 @@
         }
     } else { /* Truetype */
         scalerInfo->fontData = (unsigned char*) malloc(FILEDATACACHESIZE);
-        ftstream = (FT_Stream) calloc(1, sizeof(FT_StreamRec));
 
-        if (ftstream != NULL && scalerInfo->fontData != NULL) {
-            scalerInfo->directBuffer = (*env)->NewDirectByteBuffer(env,
-                                        scalerInfo->fontData,
-                                        FILEDATACACHESIZE);
-            if (scalerInfo->directBuffer != NULL) {
-                scalerInfo->directBuffer = (*env)->NewGlobalRef(env,
-                                            scalerInfo->directBuffer);
-                ftstream->base = NULL;
-                ftstream->size = filesize;
-                ftstream->pos = 0;
-                ftstream->read = (FT_Stream_IoFunc) ReadTTFontFileFunc;
-                ftstream->close = (FT_Stream_CloseFunc) CloseTTFontFileFunc;
-                ftstream->pathname.pointer = (void *) scalerInfo;
+        if (scalerInfo->fontData != NULL) {
+            FT_Stream ftstream = (FT_Stream) calloc(1, sizeof(FT_StreamRec));
+            if (ftstream != NULL) {
+                scalerInfo->directBuffer = (*env)->NewDirectByteBuffer(env,
+                                           scalerInfo->fontData,
+                                           FILEDATACACHESIZE);
+                if (scalerInfo->directBuffer != NULL) {
+                    scalerInfo->directBuffer = (*env)->NewGlobalRef(env,
+                                               scalerInfo->directBuffer);
+                    ftstream->base = NULL;
+                    ftstream->size = filesize;
+                    ftstream->pos = 0;
+                    ftstream->read = (FT_Stream_IoFunc) ReadTTFontFileFunc;
+                    ftstream->close = (FT_Stream_CloseFunc) CloseTTFontFileFunc;
+                    ftstream->pathname.pointer = (void *) scalerInfo;
 
-                memset(&ft_open_args, 0, sizeof(FT_Open_Args));
-                ft_open_args.flags = FT_OPEN_STREAM;
-                ft_open_args.stream = ftstream;
+                    memset(&ft_open_args, 0, sizeof(FT_Open_Args));
+                    ft_open_args.flags = FT_OPEN_STREAM;
+                    ft_open_args.stream = ftstream;
 
-                error = FT_Open_Face(scalerInfo->library,
-                                     &ft_open_args,
-                                     indexInCollection,
-                                     &scalerInfo->face);
-           }
-           if (error || scalerInfo->directBuffer == NULL) {
-               free(ftstream);
-           }
+                    error = FT_Open_Face(scalerInfo->library,
+                                         &ft_open_args,
+                                         indexInCollection,
+                                         &scalerInfo->face);
+                }
+                if (error || scalerInfo->directBuffer == NULL) {
+                    free(ftstream);
+                }
+            }
         }
     }