From 1492c73c6bc9356dddc1a4f66ca658f198bec807 Mon Sep 17 00:00:00 2001 From: Nikita Nemkin Date: Sun, 5 Sep 2021 13:48:33 +0500 Subject: Bug 575778 - Using Alpha transparency and Pattern leads to EXCEPTION_ACCESS_VIOLATION The fix for Bug 121220 assumes that all patterns are Image-based, leading to crashes when a gradient or solid color brush is passed to TextureBrush_GetImage. Change-Id: I2bd25e15ec29cbedda6f532414c30ea5b17abd93 Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/184471 Reviewed-by: Sravan Kumar Lakkimsetti Reviewed-by: Niraj Modi Tested-by: Niraj Modi --- .../org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java index cdc8f3c321..a89ddf86f9 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java @@ -612,6 +612,9 @@ static long createGdipFont(long hDC, long hFont, long graphics, long fontCollect * */ static long createAlphaTextureBrush(long brush, int alpha) { + if (Gdip.Brush_GetType(brush) != Gdip.BrushTypeTextureFill) { + return Gdip.Brush_Clone(brush); + } long hatchImage = Gdip.TextureBrush_GetImage(brush); if (hatchImage == 0) SWT.error(SWT.ERROR_CANNOT_BE_ZERO); long transparentHatchImage = Gdip.Image_Clone(hatchImage); -- cgit v1.2.3