8034030: [parfait] JNI exception pending in jdk/src/macosx/native/sun/awt/ImageSurfaceData.m
authorprr
Tue, 18 Mar 2014 15:52:03 -0700
changeset 23673 3b037f3a2be6
parent 23672 8e597639b984
child 23674 47a4a6183907
8034030: [parfait] JNI exception pending in jdk/src/macosx/native/sun/awt/ImageSurfaceData.m Reviewed-by: serb, jgodinez
jdk/src/macosx/native/sun/awt/ImageSurfaceData.m
--- a/jdk/src/macosx/native/sun/awt/ImageSurfaceData.m	Tue Mar 18 15:49:19 2014 -0700
+++ b/jdk/src/macosx/native/sun/awt/ImageSurfaceData.m	Tue Mar 18 15:52:03 2014 -0700
@@ -849,7 +849,7 @@
                     indexOfBest = 0;
                     distanceOfBest = DBL_MAX;
 
-                    for (i=0; i<lutDataSize; i++)
+                    for (i=0; (unsigned)i<lutDataSize; i++)
                     {
                         p2 = lutdata[i];
 
@@ -899,7 +899,7 @@
 {
     if (data != NULL)
     {
-        free(data);
+        free((void*)data);
     }
 }
 
@@ -1577,7 +1577,9 @@
     {
         static char *bimgName = "java/awt/image/BufferedImage";
         jclass bimg = (*env)->FindClass(env, bimgName);
+        CHECK_NULL_RETURN(bimg, NULL);
         sDataID = (*env)->GetFieldID(env, bimg, "sData", "Lsun/java2d/SurfaceData;");
+        CHECK_NULL_RETURN(sDataID, NULL);
     }
 
     return (*env)->GetObjectField(env, bufImg, sDataID);
@@ -1591,7 +1593,9 @@
     {
         static char *bimgName = "java/awt/image/BufferedImage";
         jclass bimg = (*env)->FindClass(env, bimgName);
+        CHECK_NULL(bimg);
         sDataID = (*env)->GetFieldID(env, bimg, "sData", "Lsun/java2d/SurfaceData;");
+        CHECK_NULL(sDataID);
     }
 
     (*env)->SetObjectField(env, bufImg, sDataID, sData);
@@ -1610,18 +1614,11 @@
         return;
         }
 
-        icm = (*env)->FindClass(env, icmName);
-        if (icm == NULL) {
-            return;
-        }
-
-        rgbID = (*env)->GetFieldID(env, icm, "rgb", "[I");
-        allGrayID = (*env)->GetFieldID(env, icm, "allgrayopaque", "Z");
-        mapSizeID = (*env)->GetFieldID(env, icm, "map_size", "I");
-        CMpDataID = (*env)->GetFieldID(env, icm, "pData", "J");
-        if (allGrayID == 0 || rgbID == 0 || mapSizeID == 0 || CMpDataID == 0) {
-        JNU_ThrowInternalError(env, "Could not get field IDs");
-        }
+        CHECK_NULL(icm = (*env)->FindClass(env, icmName));
+        CHECK_NULL(rgbID = (*env)->GetFieldID(env, icm, "rgb", "[I"));
+        CHECK_NULL(allGrayID = (*env)->GetFieldID(env, icm, "allgrayopaque", "Z"));
+        CHECK_NULL(mapSizeID = (*env)->GetFieldID(env, icm, "map_size", "I"));
+        CHECK_NULL(CMpDataID = (*env)->GetFieldID(env, icm, "pData", "J"));
     }
 
     gColorspaceRGB = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
@@ -1795,20 +1792,23 @@
         //bisdo->sdOps.Dispose = BufImg_Dispose;
 
         bisdo->array = (*env)->NewWeakGlobalRef(env, array);
+        if (array != NULL) CHECK_NULL(bisdo->array);
         bisdo->offset = offset;
         //bisdo->scanStr = scanStr;
         bisdo->scanStr = scanStride;
         //bisdo->pixStr = pixStr;
         bisdo->pixStr = pixelStride;
         if (!icm) {
-        bisdo->lutarray = NULL;
-        bisdo->lutsize = 0;
-        bisdo->icm = NULL;
+            bisdo->lutarray = NULL;
+            bisdo->lutsize = 0;
+            bisdo->icm = NULL;
         } else {
-        jobject lutarray = (*env)->GetObjectField(env, icm, rgbID);
-        bisdo->lutarray = (*env)->NewWeakGlobalRef(env, lutarray);
-        bisdo->lutsize = (*env)->GetIntField(env, icm, mapSizeID);
-        bisdo->icm = (*env)->NewWeakGlobalRef(env, icm);
+            jobject lutarray = (*env)->GetObjectField(env, icm, rgbID);
+            bisdo->lutarray = (*env)->NewWeakGlobalRef(env, lutarray);
+            if (lutarray != NULL) CHECK_NULL(bisdo->lutarray);
+            bisdo->lutsize = (*env)->GetIntField(env, icm, mapSizeID);
+            bisdo->icm = (*env)->NewWeakGlobalRef(env, icm);
+            if (icm != NULL) CHECK_NULL(bisdo->icm);
         }
         bisdo->rasbounds.x1 = 0;
         bisdo->rasbounds.y1 = 0;
@@ -1887,7 +1887,7 @@
                         Pixel32bit* src = lutdata;
                         Pixel32bit* dst = isdo->lutData;
                         jint i;
-                        for (i=0; i<isdo->lutDataSize; i++)
+                        for (i=0; (unsigned)i<isdo->lutDataSize; i++)
                         {
                             if (i != transparent_index)
                             {
@@ -1919,7 +1919,7 @@
                         Pixel32bit* src = lutdata;
                         Pixel32bit* dst = isdo->lutData;
                         jint i;
-                        for (i=0; i<isdo->lutDataSize; i++)
+                        for (i=0; (unsigned)i<isdo->lutDataSize; i++)
                         {
                             *dst = *src | mask;
                             dst++; src++;