changeset 9878:de165b9eba9c

8048524: Memory leak in jdk/src/share/native/sun/awt/image/BufImgSurfaceData.c Reviewed-by: prr, serb Contributed-by: Anton Melnikov <anton.melnikov@oracle.com>
author serb
date Wed, 30 Jul 2014 00:00:22 +0400
parents 1faccfb6cc00
children 3540bddf866b
files src/share/native/sun/awt/image/BufImgSurfaceData.c
diffstat 1 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/native/sun/awt/image/BufImgSurfaceData.c	Wed Jul 30 17:42:18 2014 +0100
+++ b/src/share/native/sun/awt/image/BufImgSurfaceData.c	Wed Jul 30 00:00:22 2014 +0400
@@ -291,7 +291,12 @@
             = (*env)->GetBooleanField(env, bisdo->icm, allGrayID);
         int *pRgb = (int *)
             ((*env)->GetPrimitiveArrayCritical(env, bisdo->lutarray, NULL));
-        CHECK_NULL_RETURN(pRgb, (ColorData*)NULL);
+
+        if (pRgb == NULL) {
+            free(cData);
+            return (ColorData*)NULL;
+        }
+
         cData->img_clr_tbl = initCubemap(pRgb, bisdo->lutsize, 32);
         if (allGray == JNI_TRUE) {
             initInverseGrayLut(pRgb, bisdo->lutsize, cData);
@@ -304,7 +309,13 @@
         if (JNU_IsNull(env, colorData)) {
             jlong pData = ptr_to_jlong(cData);
             colorData = (*env)->NewObjectA(env, clsICMCD, initICMCDmID, (jvalue *)&pData);
-            JNU_CHECK_EXCEPTION_RETURN(env, (ColorData*)NULL);
+
+            if ((*env)->ExceptionCheck(env))
+            {
+                free(cData);
+                return (ColorData*)NULL;
+            }
+
             (*env)->SetObjectField(env, bisdo->icm, colorDataID, colorData);
         }
     }