[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#905378: mplength: incorrectly handles missing lengths



Package: mpdtoys
Version: 0.25
Severity: minor
Tags: patch upstream

Some items in a playlist, such as Internet streams, may not have an
associated time. mplength will then complain with:

    Use of uninitialized value in addition (+) at ./mplength line 41,
    <GEN0> line 6021.

Checking first if times are defined fixes this.

-- System Information:
Debian Release: buster/sid
  APT prefers unstable-debug
  APT policy: (500, 'unstable-debug'), (500, 'unstable'), (1, 'experimental-debug'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.16.0-2-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_CA.UTF-8, LC_CTYPE=en_CA.UTF-8 (charmap=UTF-8) (ignored: LC_ALL set to en_CA.UTF-8), LANGUAGE=en_CA.UTF-8 (charmap=UTF-8) (ignored: LC_ALL set to en_CA.UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages mpdtoys depends on:
ii  libaudio-mpd-perl  2.004-2
ii  perl               5.26.2-6

mpdtoys recommends no packages.

Versions of packages mpdtoys suggests:
ii  libproc-daemon-perl    0.23-1
pn  libstring-approx-perl  <none>
ii  libterm-readkey-perl   2.37-1+b2
ii  mpd                    0.20.19-1+b3

-- no debconf information

-- 
|)|/  Ryan Kavanagh      | GPG: 4E46 9519 ED67 7734 268F
|\|\  https://rak.ac     |      BD95 8F7B F8FC 4A11 C97A
--- Begin Message ---
Some items in a playlist, such as Internet streams, may not have an
associated time. mplength will then complain with:

    Use of uninitialized value in addition (+) at ./mplength line 41,
    <GEN0> line 6021.

Checking first if times are defined fixes this.
---
 mplength | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/mplength b/mplength
index 621891b..1c0f157 100755
--- a/mplength
+++ b/mplength
@@ -38,7 +38,9 @@ my $pl=$mpd->playlist;
 my @list=$pl->as_items;
 my $secs=0;
 foreach my $item (@list) {
-	$secs+=$item->time;
+	if (defined $item->time) {
+		$secs+=$item->time;
+	}
 }
 my $mins=int($secs/60);
 printf "%i:%02i\n", $mins, ($secs-$mins*60);
-- 
2.18.0

--- End Message ---

Attachment: signature.asc
Description: PGP signature


Reply to: