From f96d31bc8a748329614b0808d969e26c8d710cc2 Mon Sep 17 00:00:00 2001 From: Jesse Natalie Date: Thu, 29 Feb 2024 10:11:04 -0800 Subject: [PATCH] wgl: Check for stw_device->screen before trying to destroy it The stw_device and its screen are set up independently. It's possible to have a device without a screen if the DLL is loaded but never called into, since DllMain for PROCESS_ATTACH sets up the stw_device, but the screen is initialized later on the first call to get pixel formats. If the DLL is loaded and then unloaded, don't crash. Cc: mesa-stable Reviewed-by: Erik Faye-Lund Part-of: --- src/gallium/frontends/wgl/stw_device.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/frontends/wgl/stw_device.c b/src/gallium/frontends/wgl/stw_device.c index 2f852aca0aa..655ae68be48 100644 --- a/src/gallium/frontends/wgl/stw_device.c +++ b/src/gallium/frontends/wgl/stw_device.c @@ -258,7 +258,8 @@ stw_cleanup(void) st_screen_destroy(stw_dev->fscreen); FREE(stw_dev->fscreen); - stw_dev->screen->destroy(stw_dev->screen); + if (stw_dev->screen) + stw_dev->screen->destroy(stw_dev->screen); stw_tls_cleanup();