[PATCH] wined3d: Avoid accessing the device after deactivation some more.

Henri Verbeet hverbeet at codeweavers.com
Tue Oct 16 12:16:11 CDT 2018


Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
Apparently I got "lucky" running the tests yesterday. Today, ddraw's
test_killfocus() was consistently crashing on this.
---
 dlls/wined3d/device.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 70d43e07e39..b90df20a7da 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -5315,9 +5315,13 @@ LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL
     }
     else if (message == WM_ACTIVATEAPP)
     {
-        UINT i;
+        unsigned int i = device->swapchain_count;
 
-        for (i = 0; i < device->swapchain_count; i++)
+        /* Deactivating the implicit swapchain may cause the application
+         * (e.g. Deus Ex: GOTY) to destroy the device, so take care to
+         * deactivate the implicit swapchain last, and to avoid accessing the
+         * "device" pointer afterwards. */
+        while (i--)
             wined3d_swapchain_activate(device->swapchains[i], wparam);
     }
     else if (message == WM_SYSCOMMAND)
-- 
2.11.0




More information about the wine-devel mailing list