diff options
author | Nikita Nemkin | 2018-09-27 12:07:54 +0000 |
---|---|---|
committer | Lars Vogel | 2018-09-27 15:20:15 +0000 |
commit | fb540937ebc0916d33df2b3b4b4e9f84b2a2f932 (patch) | |
tree | 4b526b1881b2885f8d4c071e8e8f3881ee5a7ee8 | |
parent | 86e1d48f8e87f99f56ea69e6675778f1807b7789 (diff) | |
download | eclipse.platform.swt-fb540937ebc0916d33df2b3b4b4e9f84b2a2f932.tar.gz eclipse.platform.swt-fb540937ebc0916d33df2b3b4b4e9f84b2a2f932.tar.xz eclipse.platform.swt-fb540937ebc0916d33df2b3b4b4e9f84b2a2f932.zip |
Bug 538381 - Loading Link class crashes with Application Verifier
Problem introduced in bug 531097.
Partially revert b33183ce0dec18efde020735ad580baed707c824 to fix.
Change-Id: Icd08b894f2fcc48ff76b3172b43b96bd1c9aad7a
Signed-off-by: Nikita Nemkin <nikita@nemkin.ru>
4 files changed, 40 insertions, 5 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/DateTime.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/DateTime.java index 6153ece08e..eeed0d5902 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/DateTime.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/DateTime.java @@ -84,10 +84,17 @@ public class DateTime extends Composite { * code, other than SWT, could create a control with * this class name, and fail unexpectedly. */ - lpWndClass.hInstance = OS.GetModuleHandle (null); + long /*int*/ hInstance = OS.GetModuleHandle (null); + long /*int*/ hHeap = OS.GetProcessHeap (); + lpWndClass.hInstance = hInstance; lpWndClass.style &= ~OS.CS_GLOBALCLASS; lpWndClass.style |= OS.CS_DBLCLKS; + int byteCount = DateTimeClass.length () * TCHAR.sizeof; + long /*int*/ lpszClassName = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); + OS.MoveMemory (lpszClassName, DateTimeClass, byteCount); + lpWndClass.lpszClassName = lpszClassName; OS.RegisterClass (lpWndClass); + OS.HeapFree (hHeap, 0, lpszClassName); } static { WNDCLASS lpWndClass = new WNDCLASS (); @@ -110,10 +117,17 @@ public class DateTime extends Composite { * code, other than SWT, could create a control with * this class name, and fail unexpectedly. */ - lpWndClass.hInstance = OS.GetModuleHandle (null); + long /*int*/ hInstance = OS.GetModuleHandle (null); + long /*int*/ hHeap = OS.GetProcessHeap (); + lpWndClass.hInstance = hInstance; lpWndClass.style &= ~OS.CS_GLOBALCLASS; lpWndClass.style |= OS.CS_DBLCLKS; + int byteCount = CalendarClass.length () * TCHAR.sizeof; + long /*int*/ lpszClassName = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); + OS.MoveMemory (lpszClassName, CalendarClass, byteCount); + lpWndClass.lpszClassName = lpszClassName; OS.RegisterClass (lpWndClass); + OS.HeapFree (hHeap, 0, lpszClassName); } static final char SINGLE_QUOTE = '\''; //$NON-NLS-1$ short date format may include quoted text static final char DAY_FORMAT_CONSTANT = 'd'; //$NON-NLS-1$ 1-4 lowercase 'd's represent day diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java index c31d51b87a..7e514bfafc 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Link.java @@ -78,10 +78,17 @@ public class Link extends Control { * code, other than SWT, could create a control with * this class name, and fail unexpectedly. */ - lpWndClass.hInstance = OS.GetModuleHandle (null); + long /*int*/ hInstance = OS.GetModuleHandle (null); + long /*int*/ hHeap = OS.GetProcessHeap (); + lpWndClass.hInstance = hInstance; lpWndClass.style &= ~OS.CS_GLOBALCLASS; lpWndClass.style |= OS.CS_DBLCLKS; + int byteCount = LinkClass.length () * TCHAR.sizeof; + long /*int*/ lpszClassName = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); + OS.MoveMemory (lpszClassName, LinkClass, byteCount); + lpWndClass.lpszClassName = lpszClassName; OS.RegisterClass (lpWndClass); + OS.HeapFree (hHeap, 0, lpszClassName); } /** diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java index e0ab4e0cd9..d6afa60b21 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java @@ -66,10 +66,17 @@ public class ProgressBar extends Control { * code, other than SWT, could create a control with * this class name, and fail unexpectedly. */ - lpWndClass.hInstance = OS.GetModuleHandle (null); + long /*int*/ hInstance = OS.GetModuleHandle (null); + long /*int*/ hHeap = OS.GetProcessHeap (); + lpWndClass.hInstance = hInstance; lpWndClass.style &= ~OS.CS_GLOBALCLASS; lpWndClass.style |= OS.CS_DBLCLKS; + int byteCount = ProgressBarClass.length () * TCHAR.sizeof; + long /*int*/ lpszClassName = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); + OS.MoveMemory (lpszClassName, ProgressBarClass, byteCount); + lpWndClass.lpszClassName = lpszClassName; OS.RegisterClass (lpWndClass); + OS.HeapFree (hHeap, 0, lpszClassName); } /** diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scale.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scale.java index 435a1cad1d..17fa407f8d 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scale.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scale.java @@ -67,10 +67,17 @@ public class Scale extends Control { * code, other than SWT, could create a control with * this class name, and fail unexpectedly. */ - lpWndClass.hInstance = OS.GetModuleHandle (null); + long /*int*/ hInstance = OS.GetModuleHandle (null); + long /*int*/ hHeap = OS.GetProcessHeap (); + lpWndClass.hInstance = hInstance; lpWndClass.style &= ~OS.CS_GLOBALCLASS; lpWndClass.style |= OS.CS_DBLCLKS; + int byteCount = TrackBarClass.length () * TCHAR.sizeof; + long /*int*/ lpszClassName = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); + OS.MoveMemory (lpszClassName, TrackBarClass, byteCount); + lpWndClass.lpszClassName = lpszClassName; OS.RegisterClass (lpWndClass); + OS.HeapFree (hHeap, 0, lpszClassName); } /** |