From 13f58a7608e6ee747db2fdbcace322b14c5cacca Mon Sep 17 00:00:00 2001
From: Frank Praznik <[EMAIL REDACTED]>
Date: Tue, 21 Jul 2026 14:38:48 -0400
Subject: [PATCH] test: Fix memory leak in testclipboard
(cherry picked from commit d63137082a62457b6095e7837a15f59b6b86be2f)
---
test/testclipboard.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/test/testclipboard.c b/test/testclipboard.c
index cd6a134f0f6ff..8fa8756c9a6f6 100644
--- a/test/testclipboard.c
+++ b/test/testclipboard.c
@@ -130,7 +130,11 @@ static float PrintClipboardText(float x, float y, const char *mime_type)
static float PrintPrimarySelectionText(float x, float y)
{
if (SDL_HasPrimarySelectionText()) {
- SDL_RenderDebugText(renderer, x, y, SDL_GetPrimarySelectionText());
+ char *text = SDL_GetPrimarySelectionText();
+ if (text) {
+ SDL_RenderDebugText(renderer, x, y, text);
+ SDL_free(text);
+ }
return SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE + 2.0f;
}
return 0.0f;