Commit 2e4bfa64 authored by Torge Matthies's avatar Torge Matthies Committed by Alexandre Julliard

winex11.drv: Avoid race condition in X11 error handling.

The err_callback* globals need to be protected from being overwritten before X11DRV_check_error is called, otherwise no or the wrong error handler might be called. Signed-off-by: 's avatarTorge Matthies <openglfreak@googlemail.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent a1bae9f2
......@@ -108,6 +108,15 @@ static CRITICAL_SECTION_DEBUG critsect_debug =
};
static CRITICAL_SECTION x11drv_section = { &critsect_debug, -1, 0, 0, 0, 0 };
static CRITICAL_SECTION x11drv_error_section;
static CRITICAL_SECTION_DEBUG x11drv_error_section_debug =
{
0, 0, &x11drv_error_section,
{ &x11drv_error_section_debug.ProcessLocksList, &x11drv_error_section_debug.ProcessLocksList },
0, 0, { (DWORD_PTR)(__FILE__ ": x11drv_error_section") }
};
static CRITICAL_SECTION x11drv_error_section = { &x11drv_error_section_debug, -1, 0, 0, 0, 0 };
struct d3dkmt_vidpn_source
{
D3DKMT_VIDPNSOURCEOWNER_TYPE type; /* VidPN source owner type */
......@@ -256,6 +265,7 @@ static inline BOOL ignore_error( Display *display, XErrorEvent *event )
*/
void X11DRV_expect_error( Display *display, x11drv_error_callback callback, void *arg )
{
EnterCriticalSection( &x11drv_error_section );
err_callback = callback;
err_callback_display = display;
err_callback_arg = arg;
......@@ -272,8 +282,10 @@ void X11DRV_expect_error( Display *display, x11drv_error_callback callback, void
*/
int X11DRV_check_error(void)
{
int res = err_callback_result;
err_callback = NULL;
return err_callback_result;
LeaveCriticalSection( &x11drv_error_section );
return res;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment