summaryrefslogtreecommitdiff
path: root/src/queue
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2020-06-11 07:06:59 +0200
committerMax Kellermann <max@musicpd.org>2020-06-11 07:07:02 +0200
commit5716cde1fbf027b1270179dcae700b3b974b1966 (patch)
tree1d609fa452d081b08dbc41fd3a70ea64b0e5350f /src/queue
parentb7a99b4a4baa42b5dd09d598741e8438e611f988 (diff)
queue/PlaylistEdit: fix crash in SetSongIdRange() while playing
An assertion failure in UpdateQueuedSong() could trigger because the `prev` parameter is always `nullptr`, but `queued` may be set. And in fact, calling UpdateQueuedSong() is only necessary when the queued song was edited, to re-queue it with the new range. Closes https://github.com/MusicPlayerDaemon/MPD/issues/901
Diffstat (limited to 'src/queue')
-rw-r--r--src/queue/PlaylistEdit.cxx9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/queue/PlaylistEdit.cxx b/src/queue/PlaylistEdit.cxx
index 9a2b37eed..8655e0894 100644
--- a/src/queue/PlaylistEdit.cxx
+++ b/src/queue/PlaylistEdit.cxx
@@ -431,6 +431,8 @@ playlist::SetSongIdRange(PlayerControl &pc, unsigned id,
if (position < 0)
throw PlaylistError::NoSuchSong();
+ bool was_queued = false;
+
if (playing) {
if (position == current)
throw PlaylistError(PlaylistResult::DENIED,
@@ -442,6 +444,10 @@ playlist::SetSongIdRange(PlayerControl &pc, unsigned id,
already; cancel that */
pc.LockCancel();
queued = -1;
+
+ /* schedule a call to UpdateQueuedSong() to
+ re-queue the song with its new range */
+ was_queued = true;
}
}
@@ -464,7 +470,8 @@ playlist::SetSongIdRange(PlayerControl &pc, unsigned id,
song.SetEndTime(end);
/* announce the change to all interested subsystems */
- UpdateQueuedSong(pc, nullptr);
+ if (was_queued)
+ UpdateQueuedSong(pc, nullptr);
queue.ModifyAtPosition(position);
OnModified();
}