From 1d5f9c7b92225afac8731c12a159af133a8a5071 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 27 Jul 2024 09:16:29 -0700 Subject: [PATCH] testaudio: fixed memory leak in SetTitleBar() --- test/testaudio.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/test/testaudio.c b/test/testaudio.c index 3509ee7222..a52bc1f16e 100644 --- a/test/testaudio.c +++ b/test/testaudio.c @@ -115,7 +115,6 @@ static Uint64 app_ready_ticks = 0; static SDLTest_CommonState *state = NULL; static Thing *things = NULL; -static char *current_titlebar = NULL; static Thing *mouseover_thing = NULL; static Thing *droppable_highlighted_thing = NULL; @@ -135,19 +134,14 @@ static Texture *soundboard_levels_texture = NULL; static void SetTitleBar(const char *fmt, ...) { - char *newstr = NULL; + char *title = NULL; va_list ap; va_start(ap, fmt); - SDL_vasprintf(&newstr, fmt, ap); + SDL_vasprintf(&title, fmt, ap); va_end(ap); - if (newstr && (!current_titlebar || (SDL_strcmp(current_titlebar, newstr) != 0))) { - SDL_SetWindowTitle(state->windows[0], newstr); - SDL_free(current_titlebar); - current_titlebar = newstr; - } else { - SDL_free(newstr); - } + SDL_SetWindowTitle(state->windows[0], title); + SDL_free(title); } static void SetDefaultTitleBar(void)