changeset 6897:22f9eedec9dd

Follow-up on RT-36812
author Felipe Heidrich <felipe.heidrich@oracle.com>
date Fri, 25 Apr 2014 09:39:55 -0700
parents 19d520422ce9
children 8117644a5e28
files modules/graphics/src/main/native-font/coretext.c modules/graphics/src/main/native-font/directwrite.cpp modules/graphics/src/main/native-font/freetype.c modules/graphics/src/main/native-font/pango.c
diffstat 4 files changed, 22 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/native-font/coretext.c	Fri Apr 25 09:06:56 2014 +0200
+++ b/modules/graphics/src/main/native-font/coretext.c	Fri Apr 25 09:39:55 2014 -0700
@@ -906,17 +906,13 @@
         jclass tmpClass = (*env)->FindClass(env, "com/sun/javafx/geom/Path2D");
         if ((*env)->ExceptionOccurred(env) || !tmpClass) {   
             fprintf(stderr, "OS_NATIVE error: JNI exception or tmpClass == NULL");
-            free(data.pointTypes);
-            free(data.pointCoords);
-            return NULL;
+            goto fail;
         }
         path2DClass = (jclass)(*env)->NewGlobalRef(env, tmpClass);
         path2DCtr = (*env)->GetMethodID(env, path2DClass, "<init>", "(I[BI[FI)V");
         if ((*env)->ExceptionOccurred(env) || !path2DCtr) {   
             fprintf(stderr, "OS_NATIVE error: JNI exception or path2DCtr == NULL");
-            free(data.pointTypes);
-            free(data.pointCoords);
-            return NULL;
+            goto fail;
         }
     }
 
@@ -926,28 +922,22 @@
         (*env)->SetByteArrayRegion(env, types, 0, data.numTypes, data.pointTypes);
         if ((*env)->ExceptionOccurred(env)) {   
             fprintf(stderr, "OS_NATIVE error: JNI exception");
-            free(data.pointTypes);
-            free(data.pointCoords);
-            return NULL;
+            goto fail;
         }
         (*env)->SetFloatArrayRegion(env, coords, 0, data.numCoords, data.pointCoords);
         if ((*env)->ExceptionOccurred(env)) {   
             fprintf(stderr, "OS_NATIVE error: JNI exception");
-            free(data.pointTypes);
-            free(data.pointCoords);
-            return NULL;
+            goto fail;
         }
         path2D = (*env)->NewObject(env, path2DClass, path2DCtr,
                                    0 /*winding rule*/,
                                    types, data.numTypes,
                                    coords, data.numCoords);
         if ((*env)->ExceptionOccurred(env) || !path2D) {   
-            fprintf(stderr, "OS_NATIVE error: JNI exception or path2D == NULL");
-            free(data.pointTypes);
-            free(data.pointCoords);
-            return NULL;
+            goto fail;
         }
     }
+fail:
     free(data.pointTypes);
     free(data.pointCoords);
     return path2D;
--- a/modules/graphics/src/main/native-font/directwrite.cpp	Fri Apr 25 09:06:56 2014 +0200
+++ b/modules/graphics/src/main/native-font/directwrite.cpp	Fri Apr 25 09:39:55 2014 -0700
@@ -1772,13 +1772,13 @@
         jclass tmpClass = env->FindClass("com/sun/javafx/geom/Path2D");
         if (env->ExceptionOccurred() || !tmpClass) {
             fprintf(stderr, "OS_NATIVE error: JNI exception or tmpClass == NULL");
-            return NULL;
+            goto fail;
         }
         path2DClass = (jclass)env->NewGlobalRef(tmpClass);
         path2DCtr = env->GetMethodID(path2DClass, "<init>", "(I[BI[FI)V");
         if (env->ExceptionOccurred() || !path2DCtr) {
             fprintf(stderr, "OS_NATIVE error: JNI exception or path2DCtr == NULL");
-            return NULL;
+            goto fail;
         }
     }
 
@@ -1794,6 +1794,7 @@
                                     coords, sink->numCoords());
           }
     }
+fail:
     delete sink;
     return result;
 }
--- a/modules/graphics/src/main/native-font/freetype.c	Fri Apr 25 09:06:56 2014 +0200
+++ b/modules/graphics/src/main/native-font/freetype.c	Fri Apr 25 09:39:55 2014 -0700
@@ -589,13 +589,13 @@
         jclass tmpClass = (*env)->FindClass(env, "com/sun/javafx/geom/Path2D");
         if ((*env)->ExceptionOccurred(env) || !tmpClass) {
             fprintf(stderr, "OS_NATIVE error: JNI exception or tmpClass == NULL");
-            return NULL;
+            goto fail;
         }
         path2DClass = (jclass)(*env)->NewGlobalRef(env, tmpClass);
         path2DCtr = (*env)->GetMethodID(env, path2DClass, "<init>", "(I[BI[FI)V");
         if ((*env)->ExceptionOccurred(env) || !path2DCtr) {
             fprintf(stderr, "OS_NATIVE error: JNI exception or path2DCtr == NULL");
-            return NULL;
+            goto fail;
         }
     }
 
@@ -605,12 +605,12 @@
         (*env)->SetByteArrayRegion(env, types, 0, data.numTypes, data.pointTypes);
         if ((*env)->ExceptionOccurred(env)) {   
             fprintf(stderr, "OS_NATIVE error: JNI exception");
-            return NULL;
+            goto fail;
         }
         (*env)->SetFloatArrayRegion(env, coords, 0, data.numCoords, data.pointCoords);
         if ((*env)->ExceptionOccurred(env)) {   
             fprintf(stderr, "OS_NATIVE error: JNI exception");
-            return NULL;
+            goto fail;
         }
         path2D = (*env)->NewObject(env, path2DClass, path2DCtr,
                                    0 /*winding rule*/,
@@ -618,9 +618,10 @@
                                    coords, data.numCoords);
         if ((*env)->ExceptionOccurred(env) || !path2D) {   
             fprintf(stderr, "OS_NATIVE error: JNI exception or path2D == NULL");
-            return NULL;
+            goto fail;
         }
     }
+fail:
     free(data.pointTypes);
     free(data.pointCoords);
     return path2D;
--- a/modules/graphics/src/main/native-font/pango.c	Fri Apr 25 09:06:56 2014 +0200
+++ b/modules/graphics/src/main/native-font/pango.c	Fri Apr 25 09:39:55 2014 -0700
@@ -134,10 +134,11 @@
     PangoAnalysis analysis = item->analysis;
     const gchar *text= (const gchar *)(str + item->offset);
     PangoGlyphString *glyphString = pango_glyph_string_new();
+    if (!glyphString) return NULL;
 
     pango_shape(text, item->length, &analysis, glyphString);
     int count = glyphString->num_glyphs;
-    if(count == 0) return NULL;
+    if(count == 0) goto fail;
 
     jintArray glyphsArray = (*env)->NewIntArray(env, count);
     jintArray widthsArray = (*env)->NewIntArray(env, count);
@@ -157,17 +158,17 @@
         (*env)->SetIntArrayRegion(env, glyphsArray, 0, count, glyphs); 
         if ((*env)->ExceptionOccurred(env)) {   
             fprintf(stderr, "OS_NATIVE error: JNI exception");
-            return NULL;
+            goto fail;
         }
         (*env)->SetIntArrayRegion(env, widthsArray, 0, count, widths);
         if ((*env)->ExceptionOccurred(env)) {   
             fprintf(stderr, "OS_NATIVE error: JNI exception");
-            return NULL;
+            goto fail;
         }
         (*env)->SetIntArrayRegion(env, clusterArray, 0, count, cluster);
         if ((*env)->ExceptionOccurred(env)) {   
             fprintf(stderr, "OS_NATIVE error: JNI exception");
-            return NULL;
+            goto fail;
         }
         if (!PangoGlyphStringFc.cached) cachePangoGlyphStringFields(env);
         result = (*env)->NewObject(env, PangoGlyphStringFc.clazz, PangoGlyphStringFc.init);
@@ -182,6 +183,8 @@
             (*env)->SetLongField(env, result, PangoGlyphStringFc.font, (jlong)analysis.font);
         }
     }
+
+fail:
     pango_glyph_string_free(glyphString);
     return result;
 }