Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLakshmi Shanmugam2018-01-09 08:02:40 +0000
committerLakshmi Shanmugam2018-01-09 12:11:24 +0000
commitd295a67446788aaad59cce7b727f276dbc859f31 (patch)
treed1951cd77f02799f2f9f92902bac40ee2490ca44 /bundles
parentcf304ebaae351699b0b0e2207b807b55f662e960 (diff)
downloadeclipse.platform.swt-d295a67446788aaad59cce7b727f276dbc859f31.tar.gz
eclipse.platform.swt-d295a67446788aaad59cce7b727f276dbc859f31.tar.xz
eclipse.platform.swt-d295a67446788aaad59cce7b727f276dbc859f31.zip
Bug 521281: GC.copyArea on widget causes Image.getImageData
ArrayIndexOutOfBoundsException on OSX Fixed size of alphaD[] and added additional check for size of alphaD[]. Change-Id: I7c1b1875489922951903bade6ba84f1427565930
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Image.java6
1 files changed, 3 insertions, 3 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Image.java
index 6d9f7563d3..fe7317c754 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Image.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Image.java
@@ -855,10 +855,10 @@ ImageData _getImageData (NSBitmapImageRep imageRep, AlphaInfo info) {
ImageData data = new ImageData((int)/*64*/width, (int)/*64*/height, (int)/*64*/bpp, palette, 1, srcData);
data.bytesPerLine = (int)/*64*/bpr;
if (imageRep.hasAlpha() && info.transparentPixel == -1 && info.alpha == -1 && info.alphaData == null) {
- byte[] alphaD = new byte[(int)/*64*/(width * height)];
+ byte[] alphaD = new byte[(int) (dataSize/4)];
int offset = (bitmapFormat & OS.NSAlphaFirstBitmapFormat) != 0 ? 0 : 3, a = 0;
- for (int i = offset; i < srcData.length; i+= 4) {
- alphaD[a++] = srcData[i];
+ for (int i = offset; i < srcData.length && a < alphaD.length; i+= 4, a++) {
+ alphaD[a] = srcData[i];
}
data.alphaData = alphaD;
} else {

Back to the top