From: Sebastian Harl Date: Thu, 19 Feb 2009 10:03:01 +0000 (+0100) Subject: Collectd::Unixsock: Improved error handling in putval(). X-Git-Tag: collectd-4.5.3~4 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=761b500347e50484622683bff7b20dd0e58e2d96;p=collectd.git Collectd::Unixsock: Improved error handling in putval(). --- diff --git a/bindings/perl/Collectd/Unixsock.pm b/bindings/perl/Collectd/Unixsock.pm index eb6e389e..44031784 100644 --- a/bindings/perl/Collectd/Unixsock.pm +++ b/bindings/perl/Collectd/Unixsock.pm @@ -287,7 +287,21 @@ sub putval } else { - my $time = $args{'time'} ? $args{'time'} : time (); + my $time; + + if ("ARRAY" ne ref ($args{'values'})) + { + cluck ("Invalid `values' argument (expected an array ref)"); + return; + } + + if (! scalar @{$args{'values'}}) + { + cluck ("Empty `values' array"); + return; + } + + $time = $args{'time'} ? $args{'time'} : time (); $values = join (':', $time, map { defined ($_) ? $_ : 'U' } (@{$args{'values'}})); }