From 8f15da8e9750c3eb213d0f53cdb7671cb7c5571f 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: (cherry picked from commit f96d31bc8a748329614b0808d969e26c8d710cc2) --- .pick_status.json | 2 +- src/gallium/frontends/wgl/stw_device.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 1042ae868a4..7d8c6b14b6c 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -2964,7 +2964,7 @@ "description": "wgl: Check for stw_device->screen before trying to destroy it", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null 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();