summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido Cella <guido@guidocella.xyz>2023-10-13 10:12:46 +0200
committerDudemanguy <random342@airmail.cc>2023-10-13 13:54:43 +0000
commitc4709342367d95d9cfb8a9355e7e66eca74b68d5 (patch)
tree31f225892ade92084d7c35274c86caa9115f60fd
parent6f83a730ba99bbdccd2278d6dfb88258d531dc44 (diff)
downloadmpv-c4709342367d95d9cfb8a9355e7e66eca74b68d5.tar.bz2
mpv-c4709342367d95d9cfb8a9355e7e66eca74b68d5.tar.xz
command: fix segfault with playlist-{next,prev}-playlist
This was wrongly assuming that playlist_path is always set for the current playlist entry, but it's only set when a file was added by expanding a playlist. The crash in playlist_get_first_in_next_playlist can be reproduced with mpv foo.mkv foo.zip, playlist-next, playlist-prev, playlist-next-playlist. You need to run playlist-next, playlist-prev first because foo.zip's playlist_path is NULL until you do that, which makes playlist_get_first_in_next_playlist return immediately. The crash in cmd_playlist_next_prev_playlist can be replicated with mpv --loop-playlist foo.zip foo.mkv, running playlist-next until foo.mkv, and playlist-play-next. Again, you need to open foo.zip first or its playlist_path is NULL which skips running strcmp(entry->playlist_path, mpctx->playlist->current->playlist_path). Fixes https://github.com/mpv-player/mpv/issues/12495#issuecomment-1760968608
-rw-r--r--common/playlist.c2
-rw-r--r--player/command.c1
2 files changed, 2 insertions, 1 deletions
diff --git a/common/playlist.c b/common/playlist.c
index e79a96b402..c1636bc695 100644
--- a/common/playlist.c
+++ b/common/playlist.c
@@ -221,7 +221,7 @@ struct playlist_entry *playlist_get_first_in_next_playlist(struct playlist *pl,
if (!entry)
return NULL;
- while (entry && entry->playlist_path &&
+ while (entry && entry->playlist_path && pl->current->playlist_path &&
strcmp(entry->playlist_path, pl->current->playlist_path) == 0)
entry = playlist_entry_get_rel(entry, direction);
diff --git a/player/command.c b/player/command.c
index a5aa087856..ad3cf598e4 100644
--- a/player/command.c
+++ b/player/command.c
@@ -5335,6 +5335,7 @@ static void cmd_playlist_next_prev_playlist(void *p)
: playlist_get_last(mpctx->playlist);
if (entry && entry->playlist_path &&
+ mpctx->playlist->current->playlist_path &&
strcmp(entry->playlist_path,
mpctx->playlist->current->playlist_path) == 0)
entry = NULL;