From 761b500347e50484622683bff7b20dd0e58e2d96 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Thu, 19 Feb 2009 11:03:01 +0100 Subject: [PATCH] Collectd::Unixsock: Improved error handling in putval(). --- bindings/perl/Collectd/Unixsock.pm | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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'}})); } -- 2.11.0