8009013: Better handling of T2K glyphs
authorjgodinez
Tue, 19 Mar 2013 14:29:34 -0700
changeset 18198 eeec61029574
parent 18197 ae73e4f50e08
child 18199 bfd86c4f4249
8009013: Better handling of T2K glyphs Reviewed-by: bae, mschoene, prr Contributed-by: jia-hong.chen@oracle.com
jdk/src/share/native/sun/font/freetypeScaler.c
--- a/jdk/src/share/native/sun/font/freetypeScaler.c	Tue Mar 19 13:26:42 2013 +0100
+++ b/jdk/src/share/native/sun/font/freetypeScaler.c	Tue Mar 19 14:29:34 2013 -0700
@@ -1351,17 +1351,22 @@
     FTScalerInfo *scalerInfo =
              (FTScalerInfo*) jlong_to_ptr(pScaler);
 
-    glyphs = (jint*) malloc(numGlyphs*sizeof(jint));
+    glyphs = NULL;
+    if (numGlyphs > 0 && 0xffffffffu / sizeof(jint) >= numGlyphs) {
+        glyphs = (jint*) malloc(numGlyphs*sizeof(jint));
+    }
     if (glyphs == NULL) {
+        // We reach here if:
+        // 1. numGlyphs <= 0,
+        // 2. overflow check failed, or
+        // 3. malloc failed.
         gp = (*env)->NewObject(env, sunFontIDs.gpClass, sunFontIDs.gpCtrEmpty);
-        if (!isNullScalerContext(context) && scalerInfo != NULL) {
-            invalidateJavaScaler(env, scaler, scalerInfo);
-        }
         return gp;
     }
 
     (*env)->GetIntArrayRegion(env, glyphArray, 0, numGlyphs, glyphs);
 
+    gpdata.numCoords = 0;
     for (i=0; i<numGlyphs;i++) {
         if (glyphs[i] >= INVISIBLE_GLYPHS) {
             continue;