Subject: | delete_RRA bugs |
delete_RRA validation allows index above rra_cnt.
delete_RRA does not delete last RRA after shift.
@@ -889,14 +889,12 @@ sub add_RRA {
sub delete_RRA {
# delete an RRA
my ($self, $idx) = @_; my $rrd=$self->{rrd};
- if ($idx > $rrd->{rra_cnt} || $idx<0) {croak("RRA index out of range\n");}
+ if ($idx >= $rrd->{rra_cnt} || $idx<0) {croak("RRA index out of range\n");}
# load RRA data, if not already loaded
if (!defined($rrd->{dataloaded})) {$self->_loadRRAdata;}
# update RRA
$rrd->{rra_cnt}--;
- for (my $i=$idx; $i<$rrd->{rra_cnt}; $i++) {
- $rrd->{rra}[$i]=$rrd->{rra}[$i+1];
- }
+ splice(@{$rrd->{rra}}, $idx, 1);
return 1;
}