summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Oetiker <tobi@oetiker.ch>2011-11-23 07:05:03 +0100
committerTobias Oetiker <tobi@oetiker.ch>2011-11-23 07:05:03 +0100
commit91d090167d30c90a7f4daff1e468ad7d0f717049 (patch)
treeb179364ce50c58bc961cfc8b74b46de99300813b
parent3c1ce9f1d0ca20479d10d5d18d66a2af416ad42a (diff)
downloadsmokeping-91d090167d30c90a7f4daff1e468ad7d0f717049.tar.gz
smokeping-91d090167d30c90a7f4daff1e468ad7d0f717049.tar.xz
make sure we stay within the bounds of the array
-rw-r--r--lib/Smokeping/matchers/Median.pm3
1 files changed, 3 insertions, 0 deletions
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};