diff options
author | Jon TURNEY <jon.turney@dronecode.org.uk> | 2012-01-22 19:31:51 +0000 |
---|---|---|
committer | Jon TURNEY <jon.turney@dronecode.org.uk> | 2012-01-25 01:14:08 +0000 |
commit | 1238028ebbf7cef1ab80d5eaaf72c831a6546f23 (patch) | |
tree | 0186e5a2081173a757f232396135cabbd74402ce | |
parent | 2fbea4385d6da1090863d8dafd295e49585e6c52 (diff) |
Avoid WIN_WINDOW_PROP races during Windows window destruction
The WIN_WINDOW_PROP is removed during WM_DESTROY handling, so it is not neccessary to
remove it in winDestroyWindowsWindow(), and doing so opens a race condition, as we may
attempt to access that property in the wndproc before the WM_DESTROY has completed.
A specific example of that race is if a WM_KILLFOCUS occurs in the window between property
removal and WM_DESTROY processing, where we will attempt to apply DeleteWindowFromAnyEvents()
on an invalid (null) WindowPtr.
Also guard against null WindowPtr in the WM_KILLFOCUS handler
See http://cygwin.com/ml/cygwin-xfree/2012-01/msg00009.html
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
-rw-r--r-- | hw/xwin/winmultiwindowwindow.c | 2 | ||||
-rw-r--r-- | hw/xwin/winmultiwindowwndproc.c | 7 |
2 files changed, 5 insertions, 4 deletions
diff --git a/hw/xwin/winmultiwindowwindow.c b/hw/xwin/winmultiwindowwindow.c index 2329d163e..aabde6b4a 100644 --- a/hw/xwin/winmultiwindowwindow.c +++ b/hw/xwin/winmultiwindowwindow.c @@ -638,8 +638,6 @@ winDestroyWindowsWindow (WindowPtr pWin) hIcon = (HICON)SendMessage(pWinPriv->hWnd, WM_GETICON, ICON_BIG, 0); hIconSm = (HICON)SendMessage(pWinPriv->hWnd, WM_GETICON, ICON_SMALL, 0); - SetProp (pWinPriv->hWnd, WIN_WINDOW_PROP, NULL); - /* Destroy the Windows window */ DestroyWindow (pWinPriv->hWnd); diff --git a/hw/xwin/winmultiwindowwndproc.c b/hw/xwin/winmultiwindowwndproc.c index 454dd5fa9..d76bb2bc9 100644 --- a/hw/xwin/winmultiwindowwndproc.c +++ b/hw/xwin/winmultiwindowwndproc.c @@ -714,9 +714,12 @@ winTopLevelWindowProc (HWND hwnd, UINT message, /* Remove our keyboard hook if it is installed */ winRemoveKeyboardHookLL (); + + /* Revert the X focus as well, but only if the Windows focus is going to another window */ if (!wParam) - /* Revert the X focus as well, but only if the Windows focus is going to another window */ - DeleteWindowFromAnyEvents(pWin, FALSE); + if (pWin) + DeleteWindowFromAnyEvents(pWin, FALSE); + return 0; case WM_SYSDEADCHAR: |