diff options
author | Dudemanguy <random342@airmail.cc> | 2023-07-05 15:11:40 -0500 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2023-07-06 13:08:23 +0000 |
commit | ee69d99bd409d31ec35ee6f6be53db4ff29a55c9 (patch) | |
tree | 74d33ae41d88d1467b82fed966e803a3300607cd /video | |
parent | 48e0ee9979c2928edef813e64592217420dbd4a0 (diff) | |
download | mpv-ee69d99bd409d31ec35ee6f6be53db4ff29a55c9.tar.bz2 mpv-ee69d99bd409d31ec35ee6f6be53db4ff29a55c9.tar.xz |
various: correctly ignore cache files with --no-config
--no-config should prevent loading user files of any type: configs,
cache, etc. For cache files, this case wasn't properly handled and it
was assumed they would always get something. vo_gpu's shader cache
actually already handles this, so it was left untouched. In theory,
demuxer cache should never have this issue because saving it to disk is
disabled by default (and likely that will never change), but go ahead
and change it for consistency's sake. Fixes some segfaults with
--no-config and various combinations of settings (particularly
--vo=gpu-next).
Diffstat (limited to 'video')
-rw-r--r-- | video/out/gpu/lcms.c | 13 | ||||
-rw-r--r-- | video/out/vo_gpu_next.c | 15 |
2 files changed, 18 insertions, 10 deletions
diff --git a/video/out/gpu/lcms.c b/video/out/gpu/lcms.c index 7880f279e6..47ea160d8c 100644 --- a/video/out/gpu/lcms.c +++ b/video/out/gpu/lcms.c @@ -359,12 +359,13 @@ bool gl_lcms_get_lut3d(struct gl_lcms *p, struct lut3d **result_lut3d, cache_dir = mp_find_user_file(tmp, p->global, "cache", ""); } - cache_file = talloc_strdup(tmp, ""); - for (int i = 0; i < sizeof(hash); i++) - cache_file = talloc_asprintf_append(cache_file, "%02X", hash[i]); - cache_file = mp_path_join(tmp, cache_dir, cache_file); - - mp_mkdirp(cache_dir); + if (cache_dir && cache_dir[0]) { + cache_file = talloc_strdup(tmp, ""); + for (int i = 0; i < sizeof(hash); i++) + cache_file = talloc_asprintf_append(cache_file, "%02X", hash[i]); + cache_file = mp_path_join(tmp, cache_dir, cache_file); + mp_mkdirp(cache_dir); + } } // check cache diff --git a/video/out/vo_gpu_next.c b/video/out/vo_gpu_next.c index a8e8e1fae5..93cf4f54d6 100644 --- a/video/out/vo_gpu_next.c +++ b/video/out/vo_gpu_next.c @@ -1381,9 +1381,10 @@ static void wait_events(struct vo *vo, int64_t until_time_us) static char *get_cache_file(struct priv *p) { + char *file = NULL; struct gl_video_opts *opts = p->opts_cache->opts; if (!opts->shader_cache) - return NULL; + goto done; char *dir = opts->shader_cache_dir; if (dir && dir[0]) { @@ -1391,9 +1392,12 @@ static char *get_cache_file(struct priv *p) } else { dir = mp_find_user_file(NULL, p->global, "cache", ""); } - char *file = mp_path_join(NULL, dir, "libplacebo.cache"); - mp_mkdirp(dir); + if (dir && dir[0]) { + file = mp_path_join(NULL, dir, "libplacebo.cache"); + mp_mkdirp(dir); + } talloc_free(dir); +done: return file; } @@ -1635,8 +1639,11 @@ static stream_t *icc_open_cache(struct priv *p, uint64_t sig, int flags) } else { cache_dir = mp_find_user_file(NULL, p->global, "cache", ""); } - char *path = mp_path_join(NULL, cache_dir, cache_name); + if (!cache_dir || !cache_dir[0]) + return NULL; + + char *path = mp_path_join(NULL, cache_dir, cache_name); stream_t *stream = NULL; if (flags & STREAM_WRITE) { mp_mkdirp(cache_dir); |