SDL: Fixed crash when the graphics driver is upgraded while the renderer is running

From eb26f439d89c6e9201117cc1eade59a982089f9a Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 2 May 2024 10:56:42 -0700
Subject: [PATCH] Fixed crash when the graphics driver is upgraded while the
 renderer is running

---
 src/render/direct3d11/SDL_render_d3d11.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/render/direct3d11/SDL_render_d3d11.c b/src/render/direct3d11/SDL_render_d3d11.c
index 14e4ac334c55f..bbde343abc511 100644
--- a/src/render/direct3d11/SDL_render_d3d11.c
+++ b/src/render/direct3d11/SDL_render_d3d11.c
@@ -2394,6 +2394,10 @@ static int D3D11_SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *c
     ID3D11SamplerState *textureSampler;
     PixelShaderConstants constants;
 
+    if (!textureData) {
+        return SDL_SetError("Texture is not currently available");
+    }
+
     D3D11_SetupShaderConstants(renderer, cmd, texture, &constants);
 
     switch (textureData->scaleMode) {