Commit faa040cd authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Clear the device if we're not removing the entry from the table in…

wined3d: Clear the device if we're not removing the entry from the table in wined3d_unregister_window(). The device may be destroyed after the window is unregistered, causing device_process_message() to access freed memory.
parent d3918683
......@@ -444,7 +444,11 @@ static LRESULT CALLBACK wined3d_wndproc(HWND window, UINT message, WPARAM wparam
proc = entry->proc;
wined3d_wndproc_mutex_unlock();
return device_process_message(device, window, unicode, message, wparam, lparam, proc);
if (device)
return device_process_message(device, window, unicode, message, wparam, lparam, proc);
if (unicode)
return CallWindowProcW(proc, window, message, wparam, lparam);
return CallWindowProcA(proc, window, message, wparam, lparam);
}
BOOL wined3d_register_window(HWND window, struct wined3d_device *device)
......@@ -515,6 +519,7 @@ void wined3d_unregister_window(HWND window)
proc = GetWindowLongPtrW(window, GWLP_WNDPROC);
if (proc != (LONG_PTR)wined3d_wndproc)
{
entry->device = NULL;
wined3d_wndproc_mutex_unlock();
WARN("Not unregistering window %p, window proc %#lx doesn't match wined3d window proc %p.\n",
window, proc, wined3d_wndproc);
......@@ -528,6 +533,7 @@ void wined3d_unregister_window(HWND window)
proc = GetWindowLongPtrA(window, GWLP_WNDPROC);
if (proc != (LONG_PTR)wined3d_wndproc)
{
entry->device = NULL;
wined3d_wndproc_mutex_unlock();
WARN("Not unregistering window %p, window proc %#lx doesn't match wined3d window proc %p.\n",
window, proc, wined3d_wndproc);
......
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