changeset 6311:a0f09271d2c5

8009013: Better handling of T2K glyphs Reviewed-by: bae, prr Contributed-by: jia-hong.chen@oracle.com
author bae
date Tue, 26 Mar 2013 11:56:00 +0400
parents 5d5ca338574f
children 2a444d8e36eb b3ccc94f79fa
files src/share/native/sun/font/freetypeScaler.c
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/native/sun/font/freetypeScaler.c	Mon Mar 25 20:18:21 2013 +0100
+++ b/src/share/native/sun/font/freetypeScaler.c	Tue Mar 26 11:56:00 2013 +0400
@@ -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;