Commit 4f59d372f8d98c91b5b48d5841e0d9d88b99dd06

Ryan C. Gordon 2019-06-11T09:29:48

direct3d: don't dereference bogus pointer if current texture was destroyed. Fixes Bugzilla #4460.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c
index d252775..e593573 100644
--- a/src/render/direct3d/SDL_render_d3d.c
+++ b/src/render/direct3d/SDL_render_d3d.c
@@ -1501,8 +1501,13 @@ D3D_RenderPresent(SDL_Renderer * renderer)
 static void
 D3D_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
 {
+    D3D_RenderData *renderdata = (D3D_RenderData *) renderer->driverdata;
     D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
 
+    if (renderdata->drawstate.texture == texture) {
+        renderdata->drawstate.texture = NULL;
+    }
+
     if (!data) {
         return;
     }