From d31543a7e6f150b623773bd1cecd8db6290337f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Sun, 12 May 2024 18:33:47 +0200 Subject: [PATCH] osdep/path-win: fix leak of portable_path --- osdep/path-win.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/osdep/path-win.c b/osdep/path-win.c index 3b104cac03..10884cb384 100644 --- a/osdep/path-win.c +++ b/osdep/path-win.c @@ -76,12 +76,19 @@ static char *mp_get_win_local_app_dir(void *talloc_ctx) return path ? mp_path_join(talloc_ctx, path, "mpv") : NULL; } +static void path_uninit(void) +{ + TA_FREEP(&portable_path); +} + static void path_init(void) { void *tmp = talloc_new(NULL); char *path = mp_get_win_exe_subdir(tmp, "portable_config"); - if (path && mp_path_exists(path)) + if (path && mp_path_exists(path)) { portable_path = talloc_strdup(NULL, path); + atexit(path_uninit); + } talloc_free(tmp); }