changeset 5261:40bfec414944

RT-33300: AIOOBE in DWGlyphLayout Reviewed-by: Philip Race
author Felipe Heidrich <felipe.heidrich@oracle.com>
date Thu, 03 Oct 2013 13:46:55 -0700
parents a217f67b7af6
children 17d67b5a5a00
files modules/graphics/src/main/java/com/sun/javafx/font/directwrite/DWGlyphLayout.java modules/graphics/src/main/java/com/sun/javafx/font/directwrite/JFXTextRenderer.java modules/graphics/src/main/java/com/sun/javafx/font/directwrite/OS.java modules/graphics/src/main/native-font/directwrite.cpp
diffstat 4 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/java/com/sun/javafx/font/directwrite/DWGlyphLayout.java	Thu Oct 03 13:39:34 2013 +1300
+++ b/modules/graphics/src/main/java/com/sun/javafx/font/directwrite/DWGlyphLayout.java	Thu Oct 03 13:46:55 2013 -0700
@@ -380,7 +380,7 @@
                         /* Keep advances to zero if font size is zero */
                         renderer.GetGlyphAdvances(advances, glyphStart);
                     }
-                    renderer.GetClusterMap(clusterMap, textStart);
+                    renderer.GetClusterMap(clusterMap, textStart, glyphStart);
                     glyphStart += renderer.GetGlyphCount();
                     textStart += renderer.GetLength();
                 }
--- a/modules/graphics/src/main/java/com/sun/javafx/font/directwrite/JFXTextRenderer.java	Thu Oct 03 13:39:34 2013 +1300
+++ b/modules/graphics/src/main/java/com/sun/javafx/font/directwrite/JFXTextRenderer.java	Thu Oct 03 13:46:55 2013 -0700
@@ -68,7 +68,7 @@
         return OS.JFXTextRendererGetGlyphOffsets(ptr, offsets, start);
     }
 
-    int GetClusterMap(short[] clusterMap, int start) {
-        return OS.JFXTextRendererGetClusterMap(ptr, clusterMap, start);
+    int GetClusterMap(short[] clusterMap, int textStart, int glyphStart) {
+        return OS.JFXTextRendererGetClusterMap(ptr, clusterMap, textStart, glyphStart);
     }
 }
--- a/modules/graphics/src/main/java/com/sun/javafx/font/directwrite/OS.java	Thu Oct 03 13:39:34 2013 +1300
+++ b/modules/graphics/src/main/java/com/sun/javafx/font/directwrite/OS.java	Thu Oct 03 13:46:55 2013 -0700
@@ -218,7 +218,7 @@
     static final native int JFXTextRendererGetGlyphIndices(long ptr, int[] glyphs, int start, int slot);
     static final native int JFXTextRendererGetGlyphAdvances(long ptr, float[] advances, int start);
     static final native int JFXTextRendererGetGlyphOffsets(long ptr, float[] offsets, int start);
-    static final native int JFXTextRendererGetClusterMap(long ptr, short[] clusterMap, int start);
+    static final native int JFXTextRendererGetClusterMap(long ptr, short[] clusterMap, int textStart, int glyphStart);
 
     //IDWriteFontFace
     static final native DWRITE_GLYPH_METRICS GetDesignGlyphMetrics(long ptr, short glyphIndex, boolean isSideways);
--- a/modules/graphics/src/main/native-font/directwrite.cpp	Thu Oct 03 13:39:34 2013 +1300
+++ b/modules/graphics/src/main/native-font/directwrite.cpp	Thu Oct 03 13:46:55 2013 -0700
@@ -1292,7 +1292,7 @@
 }
 
 JNIEXPORT jint JNICALL OS_NATIVE(JFXTextRendererGetClusterMap)
-(JNIEnv *env, jclass that, jlong arg0, jshortArray arg1, jint start) {
+(JNIEnv *env, jclass that, jlong arg0, jshortArray arg1, jint start, jint glyphStart) {
     if (!arg1) return 0;
     jshort* data = env->GetShortArrayElements(arg1, NULL);
     if (!data) return 0;
@@ -1309,7 +1309,7 @@
      * by DirectWrite has it relative to the DWRITE_GLYPH_RUN.
      */
     for (i = 0; i < copiedCount; i++) {
-        data[i + start] = map[i] + (jshort)start;
+        data[i + start] = map[i] + (jshort)glyphStart;
     }
     env->ReleaseShortArrayElements(arg1, data, NULL);
     return copiedCount;