]> git.ktnx.net Git - mpd-feeder.git/commitdiff
do not crash when the playlist is cleared
authorDamyan Ivanov <dmn@debian.org>
Tue, 16 Nov 2021 06:02:29 +0000 (06:02 +0000)
committerDamyan Ivanov <dmn@debian.org>
Tue, 16 Nov 2021 06:02:29 +0000 (06:02 +0000)
the 'playlist' idle event returns no result in this case which lead to
an attempt to dereference undefined value

lib/App/MPD/Feeder.pm

index 66f3ce179d4a3a1c7589b1bfb337c69f39d5cc10..ed5d27658da5a27a6a9d2a88b9ca5b4372f059c8 100644 (file)
@@ -174,7 +174,7 @@ use constant DEFAULT_CONFIG_FILE => '/etc/mpd-feeder/mpd-feeder.conf';
             $self->connect_mpd;
             $mpd->send('playlist')->on_done(
                 sub {
-                    my $present = scalar @{ $_[0] };
+                    my $present = scalar @{ $_[0] // [] };
 
                     $log->notice( "Playlist contains $present songs. Wanted: "
                             . $opt->target_queue_length );