Skip to content

Commit 13f58a7

Browse files
committed
test: Fix memory leak in testclipboard
(cherry picked from commit d631370)
1 parent dcea237 commit 13f58a7

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

test/testclipboard.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,11 @@ static float PrintClipboardText(float x, float y, const char *mime_type)
130130
static float PrintPrimarySelectionText(float x, float y)
131131
{
132132
if (SDL_HasPrimarySelectionText()) {
133-
SDL_RenderDebugText(renderer, x, y, SDL_GetPrimarySelectionText());
133+
char *text = SDL_GetPrimarySelectionText();
134+
if (text) {
135+
SDL_RenderDebugText(renderer, x, y, text);
136+
SDL_free(text);
137+
}
134138
return SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE + 2.0f;
135139
}
136140
return 0.0f;

0 commit comments

Comments
 (0)