lyrics: require artist and title to be both set
authorMax Kellermann <max@musicpd.org>
Sat, 14 Sep 2019 12:01:18 +0000 (14:01 +0200)
committerMax Kellermann <max@musicpd.org>
Sat, 14 Sep 2019 12:01:18 +0000 (14:01 +0200)
src/LyricsPage.cxx
src/lyrics.cxx

index ab78c5b..31fb131 100644 (file)
@@ -281,6 +281,11 @@ LyricsPage::Load(const struct mpd_song &_song) noexcept
        artist = mpd_song_get_tag(song, MPD_TAG_ARTIST, 0);
        title = mpd_song_get_tag(song, MPD_TAG_TITLE, 0);
 
+       if (artist == nullptr || title == nullptr) {
+               Cancel();
+               return;
+       }
+
        loader = lyrics_load(get_io_service(),
                             artist, title, *this);
 
index ae1dd28..2c19067 100644 (file)
@@ -21,7 +21,7 @@
 #include "plugin.hxx"
 #include "config.h"
 
-static PluginList empty, plugins;
+static PluginList plugins;
 
 void lyrics_init()
 {
@@ -33,10 +33,10 @@ lyrics_load(boost::asio::io_service &io_service,
            const char *artist, const char *title,
            PluginResponseHandler &handler)
 {
-       const char *args[3] = { artist, title, nullptr };
+       assert(artist != nullptr);
+       assert(title != nullptr);
 
-       if (artist == nullptr || title == nullptr)
-               return plugin_run(io_service, &empty, args, handler);
+       const char *args[3] = { artist, title, nullptr };
 
        return plugin_run(io_service, &plugins, args, handler);
 }