From: Damyan Ivanov Date: Tue, 16 Nov 2021 06:02:29 +0000 (+0000) Subject: do not crash when the playlist is cleared X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=02b8ebf94e41430d2c90b39e3348fc647522f697;p=mpd-feeder.git do not crash when the playlist is cleared the 'playlist' idle event returns no result in this case which lead to an attempt to dereference undefined value --- diff --git a/lib/App/MPD/Feeder.pm b/lib/App/MPD/Feeder.pm index 66f3ce1..ed5d276 100644 --- a/lib/App/MPD/Feeder.pm +++ b/lib/App/MPD/Feeder.pm @@ -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 );