From 9698e20399176a04bd01102ddaf44d73c9c8a33e Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 31 Dec 2025 08:00:26 -0800
Subject: [PATCH] gpu renderer: fixed memory leak when resizing the backbuffer
Fixes https://github.com/libsdl-org/SDL/issues/14734
---
src/render/gpu/SDL_render_gpu.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/render/gpu/SDL_render_gpu.c b/src/render/gpu/SDL_render_gpu.c
index cbb9cc6ba28fd..24a11198955e5 100644
--- a/src/render/gpu/SDL_render_gpu.c
+++ b/src/render/gpu/SDL_render_gpu.c
@@ -1457,6 +1457,8 @@ static bool CreateBackbuffer(GPU_RenderData *data, Uint32 w, Uint32 h, SDL_GPUTe
tci.sample_count = SDL_GPU_SAMPLECOUNT_1;
tci.usage = SDL_GPU_TEXTUREUSAGE_COLOR_TARGET | SDL_GPU_TEXTUREUSAGE_SAMPLER;
+ SDL_ReleaseGPUTexture(data->device, data->backbuffer.texture);
+
data->backbuffer.texture = SDL_CreateGPUTexture(data->device, &tci);
data->backbuffer.width = w;
data->backbuffer.height = h;