Skip to content

Commit

Permalink
Fix memory leak when destroying text
Browse files Browse the repository at this point in the history
The engine's `DestroyText` function is
never called, as well as the frees for some
internal components.
This fixes memory leaks reported by some users.

Signed-off-by: Mirko Covizzi <[email protected]>
  • Loading branch information
MirkoCovizzi authored and slouken committed Nov 14, 2024
1 parent f20defe commit 4a8bda9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/SDL_ttf.c
Original file line number Diff line number Diff line change
Expand Up @@ -4863,6 +4863,18 @@ void TTF_DestroyText(TTF_Text *text)
return;
}

DestroyEngineText(text);

if (text->internal->ops) {
SDL_free(text->internal->ops);
}
if (text->internal->clusters) {
SDL_free(text->internal->clusters);
}
if (text->internal->layout->lines) {
SDL_free(text->internal->layout->lines);
}

TTF_SetTextFont(text, NULL);
SDL_DestroyProperties(text->internal->props);
SDL_free(text->text);
Expand Down

0 comments on commit 4a8bda9

Please sign in to comment.