diff -r e899a0b780a8 javafx-font-native/src/coretext.c --- a/javafx-font-native/src/coretext.c Thu Jun 27 13:07:19 2013 -0700 +++ b/javafx-font-native/src/coretext.c Thu Jun 27 13:26:57 2013 -0700 @@ -924,11 +924,10 @@ } } -jclass path2DClass = NULL; -jmethodID path2DCtr = NULL; JNIEXPORT jobject JNICALL OS_NATIVE(CGPathApply) (JNIEnv *env, jclass that, jlong arg0) { + jobject path2D = NULL; PathData data; data.pointTypes = (jbyte*)malloc(sizeof(jbyte) * DEFAULT_LEN_TYPES); data.numTypes = 0; @@ -939,6 +938,8 @@ CGPathApply((CGPathRef)arg0, &data, pathApplierFunctionFast); + static jclass path2DClass = NULL; + static jmethodID path2DCtr = NULL; if (path2DClass == NULL) { jclass tmpClass = (*env)->FindClass(env, "com/sun/javafx/geom/Path2D"); path2DClass = (jclass)(*env)->NewGlobalRef(env, tmpClass); @@ -950,12 +951,14 @@ if (types && coords) { (*env)->SetByteArrayRegion(env, types, 0, data.numTypes, data.pointTypes); (*env)->SetFloatArrayRegion(env, coords, 0, data.numCoords, data.pointCoords); - return (*env)->NewObject(env, path2DClass, path2DCtr, - 0 /*winding rule*/, - types, data.numTypes, - coords, data.numCoords); - } - return NULL; + path2D = (*env)->NewObject(env, path2DClass, path2DCtr, + 0 /*winding rule*/, + types, data.numTypes, + coords, data.numCoords); + } + free(data.pointTypes); + free(data.pointCoords); + return path2D; } #endif /* TARGET_OS_MAC */