From ba58e2af3cd6c3c1bb224f5131eea43dfbddc2a1 Mon Sep 17 00:00:00 2001 From: llyyr Date: Wed, 23 Oct 2024 20:50:08 +0530 Subject: [PATCH] stream: normalize path before using it Alternative to #15164 --- common/playlist.c | 9 ++------- demux/demux_playlist.c | 2 +- stream/stream.c | 2 +- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/common/playlist.c b/common/playlist.c index f4950c1ab2747..0348adc927347 100644 --- a/common/playlist.c +++ b/common/playlist.c @@ -444,13 +444,8 @@ void playlist_set_current(struct playlist *pl) for (int i = 0; i < pl->num_entries; ++i) { if (!pl->entries[i]->playlist_path) continue; - char *path = pl->entries[i]->playlist_path; - if (path[0] != '.') - path = mp_path_join(NULL, pl->playlist_dir, mp_basename(pl->entries[i]->playlist_path)); - bool same = !strcmp(pl->entries[i]->filename, path); - if (path != pl->entries[i]->playlist_path) - talloc_free(path); - if (same) { + char *path = mp_normalize_path(pl, pl->entries[i]->playlist_path); + if (!strcmp(pl->entries[i]->filename, path)) { pl->current = pl->entries[i]; break; } diff --git a/demux/demux_playlist.c b/demux/demux_playlist.c index 081f9f572d662..5b37605efeda2 100644 --- a/demux/demux_playlist.c +++ b/demux/demux_playlist.c @@ -456,7 +456,7 @@ static bool scan_dir(struct pl_parser *p, char *path, if (mp_cancel_test(p->s->cancel)) break; - char *file = mp_path_join(p, path, ep->d_name); + char *file = mp_normalize_path(p, mp_path_join(p, path, ep->d_name)); struct stat st; if (stat(file, &st) == 0 && S_ISDIR(st.st_mode)) { diff --git a/stream/stream.c b/stream/stream.c index c45a6ae7ebe50..c13364265031f 100644 --- a/stream/stream.c +++ b/stream/stream.c @@ -351,7 +351,7 @@ static int stream_create_instance(const stream_info_t *sinfo, s->info = sinfo; s->cancel = args->cancel; s->url = talloc_strdup(s, url); - s->path = talloc_strdup(s, path); + s->path = mp_normalize_path(s, path); s->mode = flags & (STREAM_READ | STREAM_WRITE); s->requested_buffer_size = opts->buffer_size; s->allow_partial_read = flags & STREAM_ALLOW_PARTIAL_READ;