osdep/path-win: fix leak of portable_path

This commit is contained in:
Kacper Michajłow 2024-05-12 18:33:47 +02:00
parent 9ffbc1eef9
commit d31543a7e6
1 changed files with 8 additions and 1 deletions

View File

@ -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; return path ? mp_path_join(talloc_ctx, path, "mpv") : NULL;
} }
static void path_uninit(void)
{
TA_FREEP(&portable_path);
}
static void path_init(void) static void path_init(void)
{ {
void *tmp = talloc_new(NULL); void *tmp = talloc_new(NULL);
char *path = mp_get_win_exe_subdir(tmp, "portable_config"); 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); portable_path = talloc_strdup(NULL, path);
atexit(path_uninit);
}
talloc_free(tmp); talloc_free(tmp);
} }