changeset 1534:d217d5a72866

8159495: Fix index offsets 8140530: Creating a VolatileImage with size 0,0 results in no longer working g2d.drawString Reviewed-by: prr, psadhukhan
author aivanov
date Tue, 20 Dec 2016 02:28:54 +0000
parents 046ab73498c1
children d4302a24427c
files src/share/classes/sun/awt/image/SunVolatileImage.java src/solaris/classes/sun/java2d/x11/X11SurfaceDataProxy.java src/solaris/native/sun/java2d/x11/X11SurfaceData.c
diffstat 3 files changed, 20 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/awt/image/SunVolatileImage.java	Tue Dec 20 02:16:00 2016 +0000
+++ b/src/share/classes/sun/awt/image/SunVolatileImage.java	Tue Dec 20 02:28:54 2016 +0000
@@ -70,6 +70,10 @@
     {
         this.comp = comp;
         this.graphicsConfig = graphicsConfig;
+        if (width <= 0 || height <= 0) {
+            throw new IllegalArgumentException("Width (" + width + ")" +
+                              " and height (" + height + ") cannot be <= 0");
+        }
         this.width = width;
         this.height = height;
         this.forcedAccelSurfaceType = accType;
--- a/src/solaris/classes/sun/java2d/x11/X11SurfaceDataProxy.java	Tue Dec 20 02:16:00 2016 +0000
+++ b/src/solaris/classes/sun/java2d/x11/X11SurfaceDataProxy.java	Tue Dec 20 02:28:54 2016 +0000
@@ -102,10 +102,13 @@
                                            int w, int h)
     {
         if (cachedData == null) {
-            // Bitmask will be created lazily during the blit phase
-            cachedData = X11SurfaceData.createData(x11gc, w, h,
-                                                   x11gc.getColorModel(),
-                                                   null, 0, getTransparency());
+            try {
+                // Bitmask will be created lazily during the blit phase
+                cachedData = X11SurfaceData.createData(x11gc, w, h,
+                                                       x11gc.getColorModel(),
+                                                       null, 0, getTransparency());
+           } catch (OutOfMemoryError oome) {
+           }
         }
         return cachedData;
     }
--- a/src/solaris/native/sun/java2d/x11/X11SurfaceData.c	Tue Dec 20 02:16:00 2016 +0000
+++ b/src/solaris/native/sun/java2d/x11/X11SurfaceData.c	Tue Dec 20 02:28:54 2016 +0000
@@ -423,6 +423,15 @@
         xsdo->drawable = drawable;
         xsdo->isPixmap = JNI_FALSE;
     } else {
+        /*
+         * width , height must be nonzero otherwise XCreatePixmap
+         * generates BadValue in error_handler
+         */
+        if (width <= 0 || height <= 0 || width > 32767 || height > 32767) {
+            JNU_ThrowOutOfMemoryError(env,
+                                  "Can't create offscreen surface");
+            return JNI_FALSE;
+        }
         xsdo->isPixmap = JNI_TRUE;
         /* REMIND: workaround for bug 4420220 on pgx32 boards:
            don't use DGA with pixmaps unless USE_DGA_PIXMAPS is set.