mirror of https://github.com/mpv-player/mpv
osdep/path-win: fix leak of portable_path
This commit is contained in:
parent
9ffbc1eef9
commit
d31543a7e6
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue