From 4fdafc532037b6e6a272cc1980a160c4a7282783 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Thu, 24 Oct 2024 01:16:11 +0200 Subject: [PATCH] Do not crash when trying to reverse an empty playlist Fixes https://github.com/ncmpcpp/ncmpcpp/issues/616. --- CHANGELOG.md | 1 + src/actions.cpp | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba634f51..df4f4b59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # ncmpcpp-0.10.1 (2024-??-??) * Fix compilation with `libc++`. * Remove `autogen.sh` in favour of `autoreconf`. +* Do not crash when trying to reverse an empty playlist. # ncmpcpp-0.10 (2024-09-03) * Add the configuration option `mpd_password`. diff --git a/src/actions.cpp b/src/actions.cpp index 89405920..eaf75feb 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -1998,7 +1998,10 @@ bool ReversePlaylist::canBeRun() return false; m_begin = myPlaylist->main().begin(); m_end = myPlaylist->main().end(); - return findSelectedRangeAndPrintInfoIfNot(m_begin, m_end); + if (m_begin == m_end) + return false; + else + return findSelectedRangeAndPrintInfoIfNot(m_begin, m_end); } void ReversePlaylist::run()