Project: SWT
Bug 268787 OS: uninitialized TCHAR sizeof value usage
Reported: 2009-03-16 09:58:49 | Status: resolved fixed

TCHAR is widely used across SWT-win32 and if it is first touched (initialized) before touching OS class then an uninitialized (zero) value of TCHAR.sizeof would be used inside OS <clinit>() in the following code (thus preventing XP theme loading): int /*long*/ hHeap = OS.GetProcessHeap (); int byteCount = buffer.length () * TCHAR.sizeof; int /*long*/ pszText = OS.HeapAlloc (hHeap, HEAP_ZERO_MEMORY, byteCount); Possible solution: replace TCHAR.sizeof with its definition here: int /*long*/ hHeap = OS.GetProcessHeap (); int byteCount = buffer.length () * (IsUnicode ? 2 : 1); /* TCHAR.sizeof */ int /*long*/ pszText = OS.HeapAlloc (hHeap, HEAP_ZERO_MEMORY, byteCount); Steps to reproduce the bug: - temporarily define OS.IsWinCE field as literal (false value); - recompile OS.java and Display.java; - run org.eclipse.swt.examples.controlexample.ControlExample (on WinXP+); - go to "ProgressBar" tab (the ProgessBar will not be XP-like); or - go to "ToolTip" tab (the tool tip will not be shown even if "Visible" is checked).

Files changed in fix:
bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java