1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
Description: properly delete elements of tied hash
Origin: upstream
Bug: https://bz.apache.org/SpamAssassin/show_bug.cgi?id=8237
Index: sid/lib/Mail/SpamAssassin/DBBasedAddrList.pm
===================================================================
--- sid.orig/lib/Mail/SpamAssassin/DBBasedAddrList.pm
+++ sid/lib/Mail/SpamAssassin/DBBasedAddrList.pm
@@ -165,11 +165,10 @@ sub remove_entry {
# could be slow...
my $mailaddr = $1;
- while (my ($key, $value) = each %{$self->{accum}}) {
- # regex will catch both key and key|totscore entries and delete them
- if ($key =~ /^\Q${mailaddr}\E\|/) {
+ # regex will catch both key and key|totscore entries and delete them
+ # bug 8237 - Never use while my ($key, $value) (each %hash) to delete elements when using tied hashes
+ foreach my $key (grep {/^\Q${mailaddr}\E\|/} keys %{$self->{accum}}) {
delete $self->{accum}->{$key};
- }
}
}
}
|