From 91d090167d30c90a7f4daff1e468ad7d0f717049 Mon Sep 17 00:00:00 2001 From: Tobias Oetiker Date: Wed, 23 Nov 2011 07:05:03 +0100 Subject: make sure we stay within the bounds of the array --- lib/Smokeping/matchers/Median.pm | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib') diff --git a/lib/Smokeping/matchers/Median.pm b/lib/Smokeping/matchers/Median.pm index 24be199..35953dd 100644 --- a/lib/Smokeping/matchers/Median.pm +++ b/lib/Smokeping/matchers/Median.pm @@ -85,6 +85,9 @@ sub Test($$) my $ac = $self->{param}{old}; my $bc = $self->{param}{new}; my $cc = $ac +$bc; + my $count = scalar @{$data->{rtt}; + $cc = $count if $count < $cc; + $bc = $count if $count < $bc; my $oldm = robust_median(@{$data->{rtt}}[-$cc..-$bc-1]); my $newm = robust_median(@{$data->{rtt}}[-$bc..-1]); return abs($oldm-$newm) > $self->{param}{diff}; -- cgit v1.2.3-24-g4f1b