changeset 5569:50e268c1fb1f icedtea-2.3.5

8002325: Improve management of images Reviewed-by: prr, ahgross
author bae
date Sat, 17 Nov 2012 18:21:24 +0400
parents d89bd26ac435
children a16bf9aa6275
files src/share/native/sun/awt/image/awt_parseImage.c src/share/native/sun/awt/image/awt_parseImage.h
diffstat 2 files changed, 21 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/native/sun/awt/image/awt_parseImage.c	Thu Nov 15 19:16:41 2012 +0400
+++ b/src/share/native/sun/awt/image/awt_parseImage.c	Sat Nov 17 18:21:24 2012 +0400
@@ -223,9 +223,14 @@
         return 0;
     }
 
+    rasterP->sppsm.isUsed = 0;
+
     if ((*env)->IsInstanceOf(env, rasterP->jsampleModel,
        (*env)->FindClass(env,"java/awt/image/SinglePixelPackedSampleModel"))) {
         jobject jmask, joffs, jnbits;
+
+        rasterP->sppsm.isUsed = 1;
+
         rasterP->sppsm.maxBitSize = (*env)->GetIntField(env,
                                                         rasterP->jsampleModel,
                                                         g_SPPSMmaxBitID);
@@ -711,6 +716,21 @@
     }
     else if (cmodelP->cmType == DIRECT_CM_TYPE || cmodelP->cmType == PACKED_CM_TYPE) {
         int i;
+
+        /* do some sanity check first: make sure that
+         * - sample model is SinglePixelPackedSampleModel
+         * - number of bands in the raster corresponds to the number
+         *   of color components in the color model
+         */
+        if (!rasterP->sppsm.isUsed ||
+            rasterP->numBands != cmodelP->numComponents)
+        {
+            /* given raster is not compatible with the color model,
+             * so the operation has to be aborted.
+             */
+            return -1;
+        }
+
         if (cmodelP->maxNbits > 8) {
             hintP->needToExpand = TRUE;
             hintP->expandToNbits = cmodelP->maxNbits;
--- a/src/share/native/sun/awt/image/awt_parseImage.h	Thu Nov 15 19:16:41 2012 +0400
+++ b/src/share/native/sun/awt/image/awt_parseImage.h	Sat Nov 17 18:21:24 2012 +0400
@@ -95,6 +95,7 @@
     jint offsets[MAX_NUMBANDS];
     jint nBits[MAX_NUMBANDS];
     jint  maxBitSize;
+    jint isUsed; // flag to indicate whether the raster sample model is SPPSM
 } SPPSampleModelS_t;
 
 /* Struct that holds information for the Raster object */