Alexandre Julliard : winex11: Don' t crash when getting an invalid window in SelectionRequest.
Alexandre Julliard
julliard at winehq.org
Wed Aug 17 10:24:24 CDT 2016
Module: wine
Branch: master
Commit: 6da991c75bb4140e0922a76b5db0de3637e3f52f
URL: http://source.winehq.org/git/wine.git/?a=commit;h=6da991c75bb4140e0922a76b5db0de3637e3f52f
Author: Alexandre Julliard <julliard at winehq.org>
Date: Wed Aug 17 17:23:31 2016 +0900
winex11: Don't crash when getting an invalid window in SelectionRequest.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/winex11.drv/clipboard.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/dlls/winex11.drv/clipboard.c b/dlls/winex11.drv/clipboard.c
index 5dc5e3c..9b6c749 100644
--- a/dlls/winex11.drv/clipboard.c
+++ b/dlls/winex11.drv/clipboard.c
@@ -2298,6 +2298,11 @@ static int is_atom_error( Display *display, XErrorEvent *event, void *arg )
return (event->error_code == BadAtom);
}
+static int is_window_error( Display *display, XErrorEvent *event, void *arg )
+{
+ return (event->error_code == BadWindow);
+}
+
/**************************************************************************
* X11DRV_CLIPBOARD_InsertSelectionProperties
*
@@ -3439,6 +3444,8 @@ static void X11DRV_HandleSelectionRequest( HWND hWnd, XSelectionRequestEvent *ev
TRACE("\n");
+ X11DRV_expect_error( display, is_window_error, NULL );
+
/*
* We can only handle the selection request if :
* The selection is PRIMARY or CLIPBOARD, AND we can successfully open the clipboard.
@@ -3527,6 +3534,8 @@ END:
TRACE("Sending SelectionNotify event...\n");
XSendEvent(display,event->requestor,False,NoEventMask,(XEvent*)&result);
}
+ XSync( display, False );
+ if (X11DRV_check_error()) WARN( "requestor %lx is no longer valid\n", event->requestor );
}
More information about the wine-cvs
mailing list