[PATCH 1/3] wined3d: Clear the device if we're not removing the entry from the table in wined3d_unregister_window().
Henri Verbeet
hverbeet at codeweavers.com
Wed Jan 25 17:21:17 CST 2012
The device may be destroyed after the window is unregistered, causing
device_process_message() to access freed memory.
---
dlls/wined3d/wined3d_main.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/dlls/wined3d/wined3d_main.c b/dlls/wined3d/wined3d_main.c
index 1b7e493..ad7a5fc 100644
--- a/dlls/wined3d/wined3d_main.c
+++ b/dlls/wined3d/wined3d_main.c
@@ -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);
--
1.7.3.4
More information about the wine-patches
mailing list