From 573f0c765c9ca7f096e6f6f6708f45e59aa76bd9 Mon Sep 17 00:00:00 2001 From: Phil Race Date: Tue, 5 Jul 2016 10:29:31 -0700 Subject: [PATCH] 8159495: Fix Index Offsets Reviewed-by: flar, serb, mschoene --- .../classes/sun/java2d/x11/X11SurfaceDataProxy.java | 11 +++++++---- .../unix/classes/sun/java2d/xr/XRPMBlitLoops.java | 3 +++ .../classes/sun/java2d/xr/XRSurfaceDataProxy.java | 9 ++++++--- .../unix/native/common/java2d/x11/X11SurfaceData.c | 2 +- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/jdk/src/java.desktop/unix/classes/sun/java2d/x11/X11SurfaceDataProxy.java b/jdk/src/java.desktop/unix/classes/sun/java2d/x11/X11SurfaceDataProxy.java index fd29ac38ba2..6f21c01daeb 100644 --- a/jdk/src/java.desktop/unix/classes/sun/java2d/x11/X11SurfaceDataProxy.java +++ b/jdk/src/java.desktop/unix/classes/sun/java2d/x11/X11SurfaceDataProxy.java @@ -102,10 +102,13 @@ public abstract class X11SurfaceDataProxy extends SurfaceDataProxy 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; } diff --git a/jdk/src/java.desktop/unix/classes/sun/java2d/xr/XRPMBlitLoops.java b/jdk/src/java.desktop/unix/classes/sun/java2d/xr/XRPMBlitLoops.java index 2cfd8c2a456..3704367a9f2 100644 --- a/jdk/src/java.desktop/unix/classes/sun/java2d/xr/XRPMBlitLoops.java +++ b/jdk/src/java.desktop/unix/classes/sun/java2d/xr/XRPMBlitLoops.java @@ -138,6 +138,9 @@ public class XRPMBlitLoops { vImg = (SunVolatileImage) dst.getGraphicsConfig().createCompatibleVolatileImage(w, h, src.getTransparency()); vImg.setAccelerationPriority(1.0f); + if (!(vImg.getDestSurface() instanceof XRSurfaceData)) { + throw new InvalidPipeException("Could not create XRSurfaceData"); + } if (src.getTransparency() == SurfaceData.OPAQUE) { rgbTmpPM = new WeakReference(vImg); } else { diff --git a/jdk/src/java.desktop/unix/classes/sun/java2d/xr/XRSurfaceDataProxy.java b/jdk/src/java.desktop/unix/classes/sun/java2d/xr/XRSurfaceDataProxy.java index ddc621a3f5e..2c82e30197e 100644 --- a/jdk/src/java.desktop/unix/classes/sun/java2d/xr/XRSurfaceDataProxy.java +++ b/jdk/src/java.desktop/unix/classes/sun/java2d/xr/XRSurfaceDataProxy.java @@ -59,9 +59,12 @@ public class XRSurfaceDataProxy extends SurfaceDataProxy implements Transparency public SurfaceData validateSurfaceData(SurfaceData srcData, SurfaceData cachedData, int w, int h) { if (cachedData == null) { - cachedData = XRSurfaceData.createData(xrgc, w, h, - xrgc.getColorModel(), null, 0, - getTransparency(), true); + try { + cachedData = XRSurfaceData.createData(xrgc, w, h, + xrgc.getColorModel(), null, 0, + getTransparency(), true); + } catch (OutOfMemoryError oome) { + } } return cachedData; } diff --git a/jdk/src/java.desktop/unix/native/common/java2d/x11/X11SurfaceData.c b/jdk/src/java.desktop/unix/native/common/java2d/x11/X11SurfaceData.c index 07c13f7b7e1..0fe12d553da 100644 --- a/jdk/src/java.desktop/unix/native/common/java2d/x11/X11SurfaceData.c +++ b/jdk/src/java.desktop/unix/native/common/java2d/x11/X11SurfaceData.c @@ -441,7 +441,7 @@ jboolean XShared_initSurface(JNIEnv *env, X11SDOps *xsdo, jint depth, jint width * width , height must be nonzero otherwise XCreatePixmap * generates BadValue in error_handler */ - if (width <= 0 || height <= 0) { + if (width <= 0 || height <= 0 || width > 32767 || height > 32767) { JNU_ThrowOutOfMemoryError(env, "Can't create offscreen surface"); return JNI_FALSE;