diff options
author | Tobias Oetiker <tobi@oetiker.ch> | 2011-11-23 07:05:03 +0100 |
---|---|---|
committer | Tobias Oetiker <tobi@oetiker.ch> | 2011-11-23 07:05:03 +0100 |
commit | 91d090167d30c90a7f4daff1e468ad7d0f717049 (patch) | |
tree | b179364ce50c58bc961cfc8b74b46de99300813b /lib/Smokeping | |
parent | 3c1ce9f1d0ca20479d10d5d18d66a2af416ad42a (diff) | |
download | smokeping-91d090167d30c90a7f4daff1e468ad7d0f717049.tar.gz smokeping-91d090167d30c90a7f4daff1e468ad7d0f717049.tar.xz |
make sure we stay within the bounds of the array
Diffstat (limited to 'lib/Smokeping')
-rw-r--r-- | lib/Smokeping/matchers/Median.pm | 3 |
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}; |