# HG changeset patch # User jchen # Date 1380832913 25200 # Node ID eace1945b9746f8a707b54413bde11623c0c0d4b # Parent 23b2db6ffff41043a08582b93b939de11d4e22ab 8025664: [parfait] warnings from b62 for jdk.src.share.native.sun.font Reviewed-by: prr, jgodinez diff -r 23b2db6ffff4 -r eace1945b974 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); + } + } } }