Henri Verbeet : wined3d: Clear the device if we' re not removing the entry from the table in wined3d_unregister_window().

Alexandre Julliard julliard at winehq.org
Thu Jan 26 14:49:24 CST 2012


Module: wine
Branch: master
Commit: faa040cd9e9f34a6abdf80833912bfdd581b9921
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=faa040cd9e9f34a6abdf80833912bfdd581b9921

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Thu Jan 26 00:21:17 2012 +0100

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.

---

 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);




More information about the wine-cvs mailing list